rust_decimal vs bigdecimal: Choosing a Money Type in Rust
A developer compared Rust's main money-handling options by building a test crate with rust_decimal 1.43.0 and bigdecimal 0.4.11. Their tests found that rust_decimal silently drops digits beyond its 96-bit mantissa when parsing, while from_str_exact returns an underflow error. They argue that the common advice of fixed-size versus arbitrary precision is not enough to make a decision. The article reviews five options, including f64, integer minor units, i128, rust_decimal and bigdecimal, and notes that f64 fails basic arithmetic tests. The author concludes that integer minor units suit fiat ledgers, while decimal crates suit rates and fees and bigdecimal suits inputs beyond 28 digits.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in