https://github.com/alkis/decimal
Decimal Floating Point arithmetic for rust
https://github.com/alkis/decimal
decimal financial floating-point rust
Last synced: 6 months ago
JSON representation
Decimal Floating Point arithmetic for rust
- Host: GitHub
- URL: https://github.com/alkis/decimal
- Owner: alkis
- License: apache-2.0
- Created: 2015-12-04T14:54:26.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-28T03:42:35.000Z (over 2 years ago)
- Last Synced: 2025-03-28T18:17:28.022Z (6 months ago)
- Topics: decimal, financial, floating-point, rust
- Language: C
- Size: 7.27 MB
- Stars: 80
- Watchers: 3
- Forks: 27
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# decimal
[](https://travis-ci.org/alkis/decimal)

[](https://crates.io/crates/decimal)
Decimal Floating Point arithmetic for rust based on the [decNumber
library](http://speleotrove.com/decimal/decnumber.html).The library provides d128 which is a [128-bit decimal floating
point](https://en.wikipedia.org/wiki/Decimal128_floating-point_format) number.
You can use it as other primitive numbers in Rust. All operators are overloaded
to allow ergonomic use of this type.To emulate literals a macro is used `d128!`.
[Documentation](https://docs.rs/decimal)
# Example
```rust
let x = d128!(1.234);
let y = d128!(1.111);
let z = d128!(2.345);
assert_eq(x + y, z);
```# Running the [decTest](http://speleotrove.com/decimal/dectest.html) test suite
```bash
$ cargo build
$ ./target/debug/run-test decTest/decQuad.decTest
```