oscbyspro / Ultimathnum

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

Update binary integer description format #133

Closed oscbyspro closed 1 week ago

oscbyspro commented 1 week ago

This patch addresses the above issue by removing the neutral mask ("#") from the current binary integer description format. It also updates internal methods to ease support of future formats. In particular, I may want to encode and decode radix indicator prefixes ("0x") at some point. The internal algorithms now accept an arbitrary prefix sequence.

oscbyspro commented 1 week ago

Additionally, the TextInt/encode(...) methods now allocate the prefix in a U8 or U16, which I think is kind of cute. It makes the new implementation a bit faster for small inputs. Big integer inputs obviously don't care about such optimizations, however. Edit: I suppose all small prefix sequences (max: "-0x&") fit in a U32, so I may make this part non-generic too.