Decimal Floating Point arithmetic for rust based on the decNumber library.
The library provides d64 and d128 which are 64 bit floating point respectively 128-bit decimal floating point numbers. These types offer 16 digits and 34 digits of precision. You can use it as other primitive numbers in Rust. All operators are overloaded to allow ergonomic use of this type.
To emulate literals two macros u64!
and d128!
are used.
let x = d128!(1.234);
let y = d128!(1.111);
let z = d128!(2.345);
assert_eq(x + y, z);
Running the decTest test suite
$ cargo build
$ ./target/debug/run-test decTest/decQuad.decTest