We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The rust docs say the following about overflowing shift:
If the shift value is too large, then value is masked (N-1) where N is the number of bits, and this value is then used to perform the shift. (Source: https://doc.rust-lang.org/std/primitive.u64.html#method.overflowing_shl) And you can see this via the following code:
#[allow(arithmetic_overflow)] fn main() { let a: u64 = 500; let b = a << 119; println!("{}", b); }
Which prints 18014398509481984000.
18014398509481984000
On the other hand in the implementation here zeros will be returned:
crypto-bigint/src/uint/shl.rs
Line 18 in 36dbb69
The text was updated successfully, but these errors were encountered:
cc @mikelodder7
Sorry, something went wrong.
FYI to achieve the same behavior as libstd we can just add n = n % (Limb::BIT_SIZE * LIMBS) at the start of that function
n = n % (Limb::BIT_SIZE * LIMBS)
std
Successfully merging a pull request may close this issue.
The rust docs say the following about overflowing shift:
Which prints
18014398509481984000
.On the other hand in the implementation here zeros will be returned:
crypto-bigint/src/uint/shl.rs
Line 18 in 36dbb69
The text was updated successfully, but these errors were encountered: