Function libmodbus_rs::get_float_dcba [] [src]

pub fn get_float_dcba(src: &[u16; 2]) -> f32

get_float_dcba - get a float value from 2 registers in DCBA byte order

The get_float_dcba() function shall get a float from 4 bytes with swapped bytes (DCBA instead of ABCD). The src slice mut contain two 16 bits values, for example, if the first word is set to 0x2000 and the second to 0x47F1, the float value will be read as 123456.0.

Return value

The function shall return a float.

Parameters

src - slice of two 16 bits values

Examples

assert_eq!(libmodbus_rs::get_float_dcba(&[0x47F1, 0x2000]), 123456.0);