-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Req. init?(words:)
method
#89
Comments
Also, is it OK to default empty words to signed integer zero? There are no such binary integer collections in Swift, but I think that's what the algorithm does without intervention. Alternatively, should the initialization fail if the collection is empty even for unsigned integers? |
Hm. I perhaps an acceptable rule is that inputs are valid if and only if they are valid outputs, meaning that |
Hm. I can make Signed<Magnitude>'s StaticBigInt initializer super elegant if the Magnitude has: init?(words: some RandomAccessCollection<UInt>, isSigned: Bool) // static signedness is OK too Edit: Welp. What I wanted to do didn't work out, but I think this method is useful enough to keep. |
I also caught a bug in the initial core integer method, as I did not pass |
I haven't thought much about it, but I figure it's possible to support some non-random-access sequences using: init(words: some Sequence<UInt>, last: UInt, isSigned: Bool) |
Being able to create integers from words from non-binary-integer sources seems useful to me.
In an immediate use case, I want to abstract integer-from-string decoding without adding niche string conversion requirements (#86). I can reasonably do this by populating a temporary words allocation and then converting that to an integer. I'm sure there are other use cases as well. Swift's BinaryInteger integer protocol only lets you do this when the words come from another binary integer, however. An
init?(words:)
method fixes that.There are other variants of this method that could be useful, but I want a compelling use case:
The text was updated successfully, but these errors were encountered: