128-bit wide floating point implementation for Rust
cargo add decimal128
This crate is a work-in-progress and does not have all applicable methods implemented as per IEEE Standard for Floating-Point Arithmetic and MongoDB Decimal128 BSON type. The following methods are currently implemented:
Decimal128.from_raw_bytes
Decimal128.zero
Decimal128.is_nan
Decimal128.is_negative
Decimal128.is_zero
Decimal128.to_string
use decimal128;
let vec: [u8; 16] = [
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
];
let dec128 = Decimal128::from_raw_buf(vec);
let string = dec128.to_string();
assert_eq!("-Infinity".to_string(), string);
Licensed under the Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) at your option.