#byte-array #integer #floating #convert #numbers #floating-point #0u8

macro fi2b

Convert floating point and integer numbers into bytes and put them into an array

1 stable release

1.0.0 Jan 19, 2024

#66 in Data formats

MIT license

5KB
62 lines

fi2b

Rust version documentation LICENSE

Convert floating point and integer numbers into bytes and put them into an array

let a: &[u8] = &fi2b![1, 2, 1.0, -1.0];
assert_eq!(
    a,
    [1u8, 0u8, 0u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8, 0u8, 128u8, 63u8, 0u8, 0u8, 128u8, 191u8]
)

Dependencies

~300–740KB
~18K SLoC