Support for large binary numbers

I have a rather uncommon usage and need for large binary integers, larger than UInt64 with a base 2 radix. Implementing my solution in python was pretty easy but since the maximum size of a UInt64 in Swift is 64 bits, there does not seem to be an easy way to handle it. There was also no way to init a Decimal with a radix other than 10. Is there any thought to having a type that is similar to Python in that it is not restricted to the number of bits? Or perhaps adding a radix to Decimal init would do this? I see there is a big int in the Swift Test source but it is not exposed as part of the standard library.

Thank you, this is good, but requires an external library, thinking it would be good to have it in standard lib.

Cool! Thanks! Apparently, there has been thought and it looks like it has been proposed. Wonder how it gets into libraries.

Looks like it will soon be part of the Numerics Package. https://github.com/apple/swift-numerics.git

Terms of Service

Privacy Policy

Cookie Policy