int8

Function int8 

Source
pub fn int8(bits: &Bits) -> i8
Expand description

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

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

ยงExample

let bits = Bits::new([0xFE]);
let ibyte = bits_as::int8(&bits);

assert_eq!(ibyte, 0xFEu8 as i8);

let bits = Bits::from([0x5E]);
let ibyte = bits_as::int8(&bits);

assert_eq!(ibyte, 0xDEu8 as i8);