I’m trying to implement a fixed point type based on an i32 where the last 30 bits are the fractional bits. Things are looking good and seem to work, but the compiler warns me that the binary literals I use in the tests are out of range. I get this warning for the negative numbers, positive numbers work without warnings.
warning: literal out of range for i32 --> src\i2f30.rs:137:46 | 137 | assert_eq!(I2F30::new(-5).into_raw(), 0b11100000000000000000000000000000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The number is meant to represent -0.5, which it to my understanding should be doing, but this warning worries me. After all, an i32 should have 32 bits and all combinations of bits ought to represent a number - then why doesn’t this do it?