-
Notifications
You must be signed in to change notification settings - Fork 48
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
Instantiating a specific integer results in an overflow error, even though it clearly fits within the specified size #199
Comments
Upon further inspection, it appears that the panic occurs here, when constructing the limbs. When I add some before and after prints, this is what the compiler ends up spitting out.. // Add digit to result
println!("a");
limbs[0] += digit; // Never carries
println!("b");
|
So it appears there's a minor chance that overflow does occur in this algorithm, in which case a simple fix could be to just use |
Yes, the comment about carries is only valid for power-of-two bases. In fact it is possible to construct arbitrarily long carry propagation like so:
Basically |
Correct carry propagation when adding digits in macro (fixes #199)
Version 1.7.0 is published that includes the fix. |
Version
1.6
Platform
Darwin computer.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 x86_64
Description
Attempting to instantiate the number
258664426012969093929703085429980814127835149614277183275038967946009968870203535512256352201271898244626862047232
as aUint<384, 6>
results in overflow errors at compile time.The following code:
Resulted in this error:
When putting the
MAX
and the given integer next to each other:39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806627990306815
258664426012969093929703085429980814127835149614277183275038967946009968870203535512256352201271898244626862047232
It's clear that the integer should at the very least fit within the bounds of 384 bits.
So far from simple checks, the compiler will allow it if the number is decremented by 1, but still error if it is incremented by 1. I have not checked any other values for now, though I am capable of successfully instantiating
Uint
s of the same bitsize with much higher values, without any issue.The text was updated successfully, but these errors were encountered: