NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #678 most downloaded on crates.io
Decimal number implementation written in pure Rust suitable for financial and fixed-precision calculations.
Last release 29 days ago
02 Sep 2026
Ships fairly regularly
a new release about every 3 months
Nearly every release is documented
notes for 59 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
10 years old
107 releases · first in 2016
Fixes issue with PostgreSQL conversions whereby certain inputs would cause unexpected outputs. Issue 241.
from_str_radix whereby rounding logic would kick in too early,
especially with radix less than 10. Issue 242.from_str (implicity from_str_radix) would panic when there was overflow
and overflow significant digit was < 5. Issue 246.bytes and byteorder optional since they're only used in the postgres feature and tests.from_i128_with_scale when i128::MIN was provided.Thank you to @serejkaaa512, @AbsurdlySuspicious and @0e4ef622 for your contributions!
One column per quarter.
Added additional RoundStrategy abilities: RoundUp to always round up and RoundDown to always round down.
RoundStrategy abilities: RoundUp to always round up and RoundDown to always round down.Special thank you to @jean-airoldie for adding the additional rounding strategies and to @pfrenssen for fixing an issue in the README.
Performance improvements for to_f64 when using a scale > 0.
to_f64 when using a scale > 0.Special thank you to @hengchu who discovered and resolved the issue!
Deprecate set_sign and replace with set_sign_positive and set_sign_negative. This is intended to improve the readability of the API.
dec! macro.set_sign and replace with set_sign_positive and set_sign_negative. This is intended
to improve the readability of the API.f64 values. The base 2 mantissa of the float was assuming guaranteed accuracy
of 53 bit precision, however 52 bit precision is more accurate (f64 only).Error::description.Replace num dependency with num_trait - implemented Signed and Num traits.
num dependency with num_trait - implemented Signed and Num traits.Fixes issue whereby overflow would occur reading from PostgreSQL with high precision. The library now handles this by rounding high precision numbers
Retain trailing zeros from PostgreSQL. This ensures that the scale is maintained when serialized into the Decimal type.
k1 == k2 -> hash(k1) == hash(k2)Special thanks to @hathawsh for their help in this release!
Update to Postgres 0.17 and add postgres async/await support via tokio-pg
tokio-pgserde-floatSpecial thanks to @pimeys and @kaibyao!
Updates dependencies to prevent build issues.
Updates dependencies to prevent build issues.
Fixes issue where scaling logic produced incorrect results when one arm was a high precision zero. Thank you @KonishchevDmitry!
Bug fix release:
Fixes issue where ToSql was incorrectly calculating weight when whole portion = numeric portion.
Bug fix release:
ToSql was incorrectly calculating weight when whole portion = numeric portion.Decimal::new incorrectly handled i64::max_value() and i64::min_value().rem operation incorrectly returned results when scale was required.This release represents the start of semantic versioning and allows the library to start making fundamental improvements under the guise of V2.0. Lead
This release represents the start of semantic versioning and allows the library to start making fundamental improvements
under
the guise of V2.0. Leading up to that I expect to release 1.x versions which will include adding
various mathematical functions such as pow, ln, log10 etc.
Version 1.0.0 does come with some new features:
checked_add, checked_sub, checked_mul, checked_div and checked_rem.max_value() and min_value() for i32 and i64.Special thanks to @0e4ef622 for their help with this release!
Add prelude to help num trait inclusion (use rust_decimal::*)
use rust_decimal::prelude::*)Default trait to the library. This is equivalent to using Decimal::zero()Special thanks to @jean-airoldie for his help with this release!
Fall back to from_scientific when from_str fails during deserialization. Thanks @mattjbray!
from_scientific when from_str fails during deserialization. Thanks @mattjbray!Sum trait implementationFixes a bug in floor and ceil where negative numbers were incorrectly handled.
floor and ceil where negative numbers were incorrectly handled.Macros are now supported on stable. This does use a hack for the meantime so due diligence is required before usage.
const_fn support via a feature flag. In the future this will be the default option however in order to support older
compiler versions is behind a feature flag.Macros (nightly) now output structural data as opposed to serialized data. This is fully backwards compatible and results in some minor performance im
Bumped dependencies to remove some legacy serialization requirements.
Special thanks to @xilec, @snd and @AndrewSpeed for their help with this release.
Special thanks to @xilec, @snd and @AndrewSpeed for their help with this release.
round_dp_with_strategy. Previously default rounding support used bankers
rounding by default whereas now you can choose to round the half way point either up or down.Debug trait now outputs the actual decimal number by default to make it more useful within consuming libraries (
e.g. criterion.rs). To get something similar to the previous functionality you can use the unpack argument - this
is likely for core rust-decimal library maintainers.rescale, sub and div.Performance optimization for add.
add.Introduces the Neg trait to support the ability to use -decimal_variable.
Neg trait to support the ability to use -decimal_variable.This release updates the published documentation only and is a no-op for functionality.
This release updates the published documentation only and is a no-op for functionality.
Introduces from_scientific allowing parsing of scientific notation into the Decimal type.
from_scientific allowing parsing of scientific notation into the Decimal type.Fixes bug in rescale whereby scaling which invoked rounding incorrectly set the new scale for the left/right sides.
rescale whereby scaling which invoked rounding incorrectly set the new scale for the left/right sides.Fixes bug in cmp whereby two negatives would return an incorrect result.
cmp whereby two negatives would return an incorrect result.abs, floor and ceil functions.This is a minor version bump as we slowly build our way towards 1.0. Thank you for everyone's support and help as we get there! This has a few notable
This is a minor version bump as we slowly build our way towards 1.0. Thank you for everyone's support and help as we get there! This has a few notable changes - also introducing a few new interfaces which is the reason for the version bump:
from_parts function to allow effective creation of Decimal's without requiring binary serialization. An example of
this benefit is with the lazy static group initializers for Postgres.normalize function to allow stripping trailing zero's easily.trunc function allows truncation of a number without any rounding. This effectively "truncates" the fractional part
of the number.fract function returns the fractional part of the number without the integral._ would cause numbers to be incorrectly identified.mul. Numbers utilizing the lo portion of the decimal only will now be shortcut and bigger
numbers will now correctly overflow. True overflows will still panic, however large underflows will now be rounded as
necessary as opposed to panicing.Hash was implemented by convention in 0.6.5 however is reimplemented explicitly in 0.7.0 for effectiveness.normalize (i.e. avoiding strings). Further
optimizations can be made in write however require some div optimizations first.Fixes issue with rescale sometimes causing a silent overflow which led to incorrect results during addition, subtraction and compare. Consequently Dec
Fixes issue with rescale sometimes causing a silent overflow which led to incorrect results during addition, subtraction and compare. Consequently Decimal now rounds the most significant number so that these operations work successfully.
In addition, Decimal now derive's the Hash trait so that it can be used for indexing.
Fixes silent overflow errors when parsing highly significant strings. from_str will now round in these scenario's, similar to oleaut32 behavior.
Fixes silent overflow errors when parsing highly significant strings. from_str will now round in these scenario's,
similar to oleaut32 behavior.
Fixes a regression in ordering where by different scales would be rescaled towards losing precision instead of increasing precision. Have added numero
Fixes a regression in ordering where by different scales would be rescaled towards losing precision instead of
increasing precision. Have added numerous test suites to help cover more issues like this in the future.
Also fixes an issue in parsing invalid strings whereby the precision exceeded our maximum precision. Previously, this
would work with unintended results however this now returns an Error returned from FromStr.
Fixes an issue with division of rational numbers allowing results greater than MAX_PRECISION. This would ultimately cause issues for future operations
Fixes an issue with division of rational numbers allowing results greater than MAX_PRECISION. This would ultimately
cause issues for future operations on this number.
In addition, in some cases transitive operations would not be equal due to overflow being lost.
This minor release is purely to expose rust_decimal_macros for use on the nightly channel. Documentation has been updated accordingly.
This minor release is purely to expose rust_decimal_macros for use on the nightly channel. Documentation has been
updated accordingly.
This release has a few major changes to the internal workings of the Decimal implementation and consequently comes with a number of performance improv
This release has a few major changes to the internal workings of the Decimal implementation and consequently comes
with a number of performance improvements.
Decimal type using from_f32 and from_f64.add, sub, mul run roughly 1500% faster than before.div run's roughly 1000% faster than before with room for future improvement.cmp, rescale, round_dp and some string manipulations.*Assign traits for simpler usage.BigInt and BigUint as being intermediary data types.Minor bug fix to prevent a panic from overflow during comparison of high significant digit decimals.
Minor bug fix to prevent a panic from overflow during comparison of high significant digit decimals.
Minor bux fix to prevent panic upon parsing an empty string.
Minor bux fix to prevent panic upon parsing an empty string.
Removes postgres from default feature set.
bincode support for serdeFixes bug in cmp whereby negative's were not being compared correctly.
Fixes bug in cmp whereby negative's were not being compared correctly.
Minor bug fix to support creating negative numbers using the default constructor.
Minor bug fix to support creating negative numbers using the default constructor.
This release is a stylistic cleanup however does include some minor changes that may break existing builds.
This release is a stylistic cleanup however does include some minor changes that may break existing builds.
features using the keyword serde.0.f64 conversion support has been added.This is a documentation release that should help with discoverability and usage.
This is a documentation release that should help with discoverability and usage.
Removed trait ToDecimal and replaced with builtin `From` trait (`#12`)
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →