Function int16

Source
pub fn int16(bits: &Bits) -> i16
Expand description

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

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

ยงExample

let bits = Bits::new([0x10, 0xFE]);
let ishort = bits_as::int16(&bits);

assert_eq!(ishort, 0xFE10u16 as i16);

let bits = Bits::from([0x10, 0x5E]);
let ishort = bits_as::int16(&bits);

assert_eq!(ishort, 0xDE10u16 as i16);