Crates.io | mpdec |
lib.rs | mpdec |
version | 4.0.1 |
created_at | 2025-06-27 01:54:21.084952+00 |
updated_at | 2025-06-27 01:54:21.084952+00 |
description | wrapper for libmpdec math library |
homepage | |
repository | https://gitlab.com/omnid/rust-crates/mpdec |
max_upload_size | |
id | 1728059 |
size | 54,305 |
Rust wrapper around libmpdec — a high-performance C library for arbitrary-precision decimal floating point arithmetic.
Built on top of raw FFI bindings (mpdec-sys
), this crate provides idiomatic Rust types and operations for working with decimal numbers with precise rounding behavior and conformance to the General Decimal Arithmetic Specification.
use std::str::FromStr;
use mpdec::Decimal;
fn main() {
let a = Decimal::from_str("1.2345").unwrap();
let b = Decimal::from_str("2.0000").unwrap();
let c = a * b;
println!("Result: {}", c); // Result: 2.4690
}