| Crates.io | ieee-754 |
| lib.rs | ieee-754 |
| version | 0.1.4 |
| created_at | 2025-02-05 14:15:46.313542+00 |
| updated_at | 2025-02-22 14:07:10.537624+00 |
| description | A library to convert a hexadecimal value to a 32-bit or 64-bit floating-point precision following the IEEE 754 standard. |
| homepage | https://github.com/j-p-d-e-v/IEEE754 |
| repository | https://github.com/j-p-d-e-v/IEEE754 |
| max_upload_size | |
| id | 1544037 |
| size | 33,409 |
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/
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::to_64bit_float(values.clone());
println!("Input: {:x?}", values);
println!("Expected Output: {}", -74.74597276138431);
assert_eq!(-74.74597276138431, test);
Converting a hexadecimal to 32-bit floating-point value using IEEE754 single precision.
use crate::ieee754::IEEE754;
let values = vec![0x00, 0x00, 0x00, 0x00];
let test: f32= IEEE754::to_32bit_float(values.clone()).unwrap();
println!("Input: {:x?}", values);
println!("Expected Output: {}", 0.0);
assert_eq!(0.0, test);
Converting a 32-bit floating point to hexadecimal value using IEEE754 single precision.
use crate::ieee754::IEEE754;
let values = -33.33333333;
let output = IEEE754::to_32bit_hex(values.clone());
println!("Input: {:x?}", values);
println!("Expected Output: C2055555");
assert_eq!(output.unwrap(), "C2055555");
Converting a 64-bit floating point to hexadecimal value using IEEE754 double precision.
use crate::ieee754::IEEE754;
let values = -33.33333333;
let output = IEEE754::to_64bit_hex(values.clone());
println!("Input: {:x?}", values);
println!("Expected Output: C040AAAAAAA38226");
assert_eq!(output.unwrap(), "C040AAAAAAA38226");
References: