oscbyspro / Numberick

An arithmagick overhaul in Swift
Apache License 2.0
15 stars 3 forks source link

DoubleWidth as in-memory words #104

Closed oscbyspro closed 1 year ago

oscbyspro commented 1 year ago

Hm. I think DoubleWidth would be much simpler if it were stored in words order.

/// In words order:

public var low:  Low
public var high: High

/// In platform endianness order:

#if _endian(big)

public var high: High
public var low:  Low

#else

public var low:  Low
public var high: High

#endif

Pros

Cons

oscbyspro commented 1 year ago

Somebody, please ban big endianness. Such headache. No benefit.

oscbyspro commented 1 year ago

But is it possible to implement var byteSwapped: Self in words order? What would it do on big-endian platforms? Looking at littleEndian's and bigEndian's documentation

If necessary, the byte order of this value is reversed from the typical byte order of this integer type. On a little-endian platform, for any integer x, x == x.littleEndian.

If necessary, the byte order of this value is reversed from the typical byte order of this integer type. On a big-endian platform, for any integer x, x == x.bigEndian.

it seems like they require platform-endian in-memory representations (which I have). Hm.

oscbyspro commented 1 year ago

Again: somebody, please ban big endianness. Such headache. No benefit.