oscbyspro / Ultimathnum

Binary arithmetic reimagined in Swift
Apache License 2.0
4 stars 1 forks source link

Order and Signedness enums (no protocols) #37

Closed oscbyspro closed 1 week ago

oscbyspro commented 1 week ago

The Endianness or Signedness types are just constant Bool(s) at this point. The methods that used them are either inlineable, too complicated for a dynamic comparison to matter, or designated slow paths. There is some generic stuff you can do with BinaryInteger.Mode, but they are no longer relevant. I still prefer named cases over Bool(s) so I might turn them into enums, we will see.

oscbyspro commented 1 week ago

The named enum cases also let me upgrade som function signatures:

DataInt.signum(
    of:  x, mode: .unsigned
)

DataInt.compare(
    lhs: x, mode:   .signed,
    rhs: y, mode: .unsigned
)