pub fn setbits(x: u8) -> u32 {
u32::MAX >> (32 - x)
}
s3bk
3
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Apparent arithmetic bug | 21 | 1516 | April 12, 2020 | |
| Bitshift and overflowing behavior | 2 | 3048 | December 17, 2015 | |
| Why do the non-panicking variants of left bit-shift work the way they do? | 11 | 3303 | April 2, 2023 | |
|
Disable overflow check
|
14 | 2316 | July 11, 2023 | |
| >> operator panics in debug build, works in release build | 14 | 2505 | March 16, 2016 |