int32

Function int32 

Source
pub fn int32(bits: &Bits) -> i32
Expand description

Converts up to the first 32 bits of a bit string to a 32 bit signed integer.

If the length of the the bit string is less than 32, the result is sign-extended to 32 bits.

ยงExample

let bits = Bits::new([0x10, 0x32, 0x54, 0x76]);
let int = bits_as::int32(&bits);

assert_eq!(int, 0x76543210);

let bits = Bits::from([0x10, 0x32, 0x54, 0x76]);
let int = bits_as::int32(&bits);

assert_eq!(int, 0xF6543210u32 as i32);