apple / swift-numerics

Advanced mathematical types and functions for Swift
Apache License 2.0
1.68k stars 145 forks source link

Remove big/little endiant distinction in representation of DoubleWidth #209

Closed stephentyrone closed 2 years ago

stephentyrone commented 2 years ago

This doesn't really add anything that we need; it changes the in-memory layout, but that's effectively an implementation detail. We might as well simply pick one and simplify things.

This does mean that DoubleWidth types have a "weird" layout on big endian systems, but that doesn't really cause any problems for anything. This would be a problem if we sunk these types into the standard library and wanted to bridge them to/from __int128_t and friends, because the representation wouldn't match. It's also trivial to revert this change, however, since it doesn't actually intrude into any operations, so let's keep things simple for now.

stephentyrone commented 2 years ago

@swift-ci please test

stephentyrone commented 2 years ago

@swift-ci please test

xwu commented 2 years ago

Fiiine. I was really pleased with my cleverness here.

A point in favor of simplification here is that even on little endian systems there can still be an alignment mismatch between this and the non-DoubleWidth types of the same width.