oscbyspro / Ultimathnum

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

Req. big integer elements be normalized #26

Closed oscbyspro closed 2 weeks ago

oscbyspro commented 2 weeks ago

Idea: generic algorithms would never need to perform conservative normalization checks or transformations in big integer branches if big integers are required to offer normalized elements. InfiniInt\<T> already does this because it would be silly to do otherwise, but generic algorithms cannot yet assume it.

oscbyspro commented 2 weeks ago

BinaryInteger/isZero was the first use case I thought of, but I suppose I could improve it be checking the appendix bit first and performing the comparison backwards. I'm sure there are other use cases, however.

Edit: I suppose BinaryInteger/isZero would still improve somewhat since it would compare zero elements instead of one or zero elements (backwards). At the same time, big integers are kind of slow by definition so I would not put much emphasis on an element comparison.