bigdecimal
Arbitrary precision decimal numbers
0.4.10
110M downloads/mo
#759 most downloaded on crates.io
akubera/bigdecimal-rs
What this package is like to depend on
Last release 7 months ago
27 Dec 2025
Release timing varies
gaps range from 6 weeks to 1.7 years
Some releases are documented
notes for 10 of 25 stable releases
1 version withdrawn
withdrawn after publishing
9 years old
26 releases · first in 2017
2 releases in the last 12 months
see the full history below
Release timeline
26 releases · Apr 2017 to Dec 2025Releases
latest 26-
0.4.1027 Dec 2025Release notes
Open source →Changes
- Add comparison operators between BigDecimal and primitive integers
- Improve accuracy of initial iteration in square-root calculation
- Only include necessary Rust files in the released package (no extra dev-scripts when downloading)
-
0.4.919 Oct 2025Release notes
Open source →Changes
-
Add methods
BigDecimal::{powi, powi_with_context}for raising a decimal to a i64 power- the
powiuses Default Context
- the
-
Add methods
BigDecimal::mul_with_contextfor efficient multiplication to fixed precision- uses precision and rounding-mode in the Context
-
Add method
BigDecimal::decimal_digit_count, returning number of decimal digits (i.e. precision) of the number -
Add method
BigDecimal::order_of_magnitude, returning position of most significant digit of this decimal -
Add method
BigDecimal::is_one_quickcheck, returningOption<bool>indicating if the value is1.0if it can be calculated without allocating, or None if too large- Replaced
is_onein multiplication methods when used for optimizations- Should test if that actually speeds it up
- Eg value
1.00000000000000000000000000000000000000000is stored internally as
[4870020673419870208, 16114848830623546549, 293] E -41and it's hard to tell this is equivalent to 1
- Replaced
-
Add optimizations to inverse
- small powers of ten will simply flip their scale
1/10e-5 -> 10e5 - convert to f64 to make initial guess when before iterative algorithm
- small powers of ten will simply flip their scale
-
Add
Context::invert(&self, BigDecimalRef), equivalent toBigDecimal::inverse_with_context(&self, &ctx)- Still has a bug where rounding ignores sign, affecting floor/ceiling modes
-
-
0.4.801 Apr 2025Release notes
Open source →What's Changed
- Fix broken link in README.md by @jonahgao in #142
- Fix formatting a "scaled zero" value (eg
0e15 = 0*10^15) by @drinkcat in #145
Full Changelog: v0.4.7...v0.4.8
-
0.4.708 Dec 2024Release notes
Open source →Changes
- Fixed bug in
BigDecimal::to_f64 - Impl
num_traits::ToPrimitiveforBigDecimalRef - Added methods
BigDecimal::{ToPlainString,WritePlainString} - Added Justfile to repo
- Fixed bug in
-
0.4.628 Oct 2024Release notes
Open source →Changes
-
Fix error in formatting code that would skip "carrying the one" when rounding up series of nines, overflowing
-
Improved implementation of sqrt and cbrt
-
Uses consistent rounding implementations in formatting and arithmetic operations
-
Add new constructor methods
BigDecimal::from_bigint&BigDecimal::from_biguint
-
-
0.4.517 Jun 2024Release notes
Open source →Changes
-
Remove restrictions on
num-*dependencies.- num-traits and num-bigint need to be specified for users using Rust versions older than 1.60 (let me know if this should be continued to be supported)
-
Fix some bad assumptions when running in 32 bit mode.
- Uses of
as usizehave been replaced withas u64
- Uses of
-
-
0.4.415 Jun 2024Release notes
Open source →Changes
- Revert formatting semantics to match Rust's meanings rather than Python's
- The meaning of the formatting string
"{:.4}"has returned to "4 digits after decimal place" rather than "four digits of precision"
- The meaning of the formatting string
- Add new compile-time parameters for safer formatting
- Configurable thresholds prevent printing out full decimal form of large numbers, like 1e999999999999999 (could be used in)
- Improved JSON serialization / formatting routines
Note
Please add your own tests to ensure this library formats (and continues to format) numbers as you expect
-
Added methods
BigDecimalRef::clone_intoBigDecimal::set_scale(mutable version oftake_and_scale)
-
Optimized bigdecimal comparison algorithms
-
Restricted versions of num-* crates to respect Minimum Supported Rust Version (1.43)
- I may raise this up soon
- Revert formatting semantics to match Rust's meanings rather than Python's
-
0.4.305 Mar 2024Release notes
Open source →Changes
- Use exponential formatting (scientific-notation) if number of leading zeros is greater than 5
- so
1234e-304is formatted as1.234e-301rather than0.00.....(300-zeros)....00123 - Fixes "out of memory errors" when massive amounts of zeros would have been printed
- so
- Add methods for printing using scientific-notation & engineering-notation
- Add derived Clone trait to ParseBigDecimalError
- Preserve scale when adding zero
- Mimics Python's Decimal behavior:
>>> Decimal("1.2") + Decimal("0.00000") Decimal('1.20000')
- Mimics Python's Decimal behavior:
- Minor optimizations removing unnecessary clones in addition and multiplication
- Use exponential formatting (scientific-notation) if number of leading zeros is greater than 5
-
0.4.216 Oct 2023Release notes
Open source →Changes
-
Add Context struct
- For user-controlled precision and rounding
- Support for a few BigDecimal functions added (eg:
sqrt_with_context(&self, ctx: &Context)) , more to come in future versions. - Note standard operations use default (compile-time-defined) context
-
Add BigDecimalRef struct
- Non-owning BigDecimal struct that has some non-digit-changing methods (i.e. change sign/scale without copying digits) for more efficient calculations
- Implements math operations
Add,Sub - Implement
From<&BigInt> for BigDecimalRef
-
Compile-time default rounding mode may be set by environment variable
RUST_BIGDECIMAL_DEFAULT_ROUNDING_MODE -
Fix issue recompiling if
RUST_BIGDECIMAL_DEFAULT_PRECISIONhaddn't changed -
Add
BigDecimal::with_precision_round()- trim the bigdecimal after operations, rounding at given point
-
Add
BigDecimal::fractional_digit_count()- Return's the bigdecimal's "scale", (number of digits right of the decimal point)
-
Support reading subnormal floating-point numbers
-
Improve initial "guess" in calculation of inverted value.
-
Fix panic in from_str_radix (#115)
-
(internal) Reorganize std::ops implementations by moving each to separate functions (
src/impl_ops_add.rs,src/impl_ops_sub.rs, etc)
Performance Improvements
BigDecimal::eqtakes into account trailing zeros, avoids aligning digits- (internal)
ten_to_the- used everywhere to align BigIntegers within BigDecimals, all operations with high precision numbers should be faster
-
-
0.4.113 Jul 2023Release notes
Open source →Changes
-
Fix issue where RUST_BIGDECIMAL_DEFAULT_PRECISION envar would always
trigger a rebuild -
Fix issue where .neg() could be called on {signed-int}::MIN values
-
Add implementations of Add/Sub/Mul/Div for primitive values
-
Use 'proptest' crate to improve arithmetic testing
-
-
0.4.005 Jul 2023Nothing published for this version
-
0.3.109 May 2023Nothing published for this version
-
0.3.026 Aug 2021Nothing published for this version
-
0.2.226 Aug 2021Nothing published for this version
-
0.2.126 Aug 2021 withdrawnNothing published for this version
-
0.2.002 Sep 2020Nothing published for this version
-
0.1.227 Apr 2020Nothing published for this version
-
0.1.012 Apr 2019Nothing published for this version
-
0.0.1509 Feb 2019Nothing published for this version
-
0.0.1430 Jul 2018Nothing published for this version
-
0.0.1326 Jul 2018Nothing published for this version
-
0.0.1227 May 2018Nothing published for this version
-
0.0.1130 Mar 2018Nothing published for this version
-
0.0.1002 Aug 2017Nothing published for this version
-
0.0.702 May 2017Nothing published for this version
-
0.0.105 Apr 2017Nothing published for this version