I have this code:
fn main() {
println!("-1 = {:b}", -1 as i8);
println!("0b11111111 = {}", 0b11111111 as i8);
}
Both lines return the expected result, namely
-1 = 11111111
0b11111111 = -1
However, the compiler raises a warning as follows:
warning: src\main.rs:3: literal out of range for i8
note: src\main.rs:3: #[warn(overflowing_literals)] on by default
To my understanding, 0b11111111 is a valid signed integer and means -1 in decimal. Therefore the warning seems to be wrong to me.
I have this code:
Both lines return the expected result, namely
However, the compiler raises a warning as follows:
warning: src\main.rs:3: literal out of range for i8
note: src\main.rs:3: #[warn(overflowing_literals)] on by default
To my understanding,
0b11111111is a valid signed integer and means -1 in decimal. Therefore the warning seems to be wrong to me.