Function bitconv::to_int16[][src]

pub fn to_int16<T: BitConvEndian>(data: &[u8], start_index: usize) -> i16

Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.

The to_int16 function converts the bytes from index start_index to start_index + 1 to a i16 value.

Example

use bitconv::{
    endian::{Big, Little}, to_int16
};

let buffer = [15, 0, 0, 255, 3, 16, 39, 255, 255, 127];
assert_eq!(-256, to_int16::<Little>(&buffer, 2));
assert_eq!(255, to_int16::<Big>(&buffer, 2));