#floating-point #f64 #f32 #packets #convert-hex

bin+lib ieee-754

A library to convert a hexadecimal value to a 32-bit or 64-bit floating-point precision following the IEEE 754 standard

1 unstable release

0.1.3 Feb 8, 2025
0.1.2 Feb 8, 2025
0.1.1 Feb 7, 2025
0.1.0 Feb 5, 2025

#1022 in Parser implementations

Download history 321/week @ 2025-02-04 22/week @ 2025-02-11

343 downloads per month

MIT license

17KB
330 lines

IEEE 754 Floating-Point Representation

The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point computation which was established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE).

To learn more about IEEE754 kindly visit: https://www.geeksforgeeks.org/ieee-standard-754-floating-point-numbers/

Example 1:

Converting a hexadecimal to 64-bit floating-point value using IEEE754 double precision.

use crate::ieee754::IEEE754;

let values = vec![0xc0, 0x52, 0xaf, 0xbe, 0x4, 0x89, 0x76, 0x8e];
let test: IEEE754 = IEEE754::new(values.clone());
println!("Input: {:x?}", values);
println!("Expected Output: {}", -74.74597276138431);
assert_eq!(-74.74597276138431, test.to_64bit().unwrap());

Example 2:

Converting a hexadecimal to 64-bit floating-point value using IEEE754 double precision.

use crate::ieee754::IEEE754;

let values = vec![0x00, 0x00, 0x00, 0x00];
let test: IEEE754 = IEEE754::new(values.clone());
println!("Input: {:x?}", values);
println!("Expected Output: {}", 0.0);
assert_eq!(0.0, test.to_32bit().unwrap());

No runtime deps