Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mongodb-rust/decimal128
WASM-compatible Decimal128 implementation
https://github.com/mongodb-rust/decimal128
Last synced: about 2 months ago
JSON representation
WASM-compatible Decimal128 implementation
- Host: GitHub
- URL: https://github.com/mongodb-rust/decimal128
- Owner: mongodb-rust
- License: apache-2.0
- Archived: true
- Created: 2019-04-25T14:12:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T12:31:58.000Z (over 1 year ago)
- Last Synced: 2024-07-24T22:02:43.910Z (2 months ago)
- Language: Rust
- Size: 70.3 KB
- Stars: 9
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
decimal 128
128-bit wide floating point implementation for Rust
## Installation
```shell
cargo add decimal128
```## Usage
This crate is a work-in-progress and does not have all applicable methods implemented as per [IEEE Standard for Floating-Point Arithmetic](https://ieeexplore.ieee.org/document/4610935) and [MongoDB Decimal128 BSON type](https://github.com/mongodb/specifications/blob/master/source/bson-decimal128/decimal128.rst). The following methods are currently implemented:
- `Decimal128.from_raw_bytes`
- `Decimal128.zero`
- `Decimal128.is_nan`
- `Decimal128.is_negative`
- `Decimal128.is_zero`
- `Decimal128.to_string````rust
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);
```## License
Licensed under the Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
at your option.