-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Description
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
.
On the other hand in the implementation here zeros will be returned:
Line 18 in 36dbb69
return Self { limbs }; |
Metadata
Metadata
Assignees
Labels
No labels