Releases: akubera/bigdecimal-rs
v0.4.6
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
v0.4.5
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 usize
have been replaced withas u64
- Uses of
v0.4.4
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_into
BigDecimal::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
v0.4.3
Changes
- Use exponential formatting (scientific-notation) if number of leading zeros is greater than 5
- so
1234e-304
is formatted as1.234e-301
rather 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
v0.4.2
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_PRECISION
haddn'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::eq
takes 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
v0.4.1
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
v0.4.0
Changes
-
no_std
feature support #97- To disable std, change your Cargo.toml dependency to:
bigdecimal = { version = "0.4", default-features = false }
- Still depends on alloc (I think we will always need dynamic storage)
- To disable std, change your Cargo.toml dependency to:
-
Allow user to set default max-precision at compile time
- Use environment variable
RUST_BIGDECIMAL_DEFAULT_PRECISION
- Defaults to 100
- This "is the number of 3s in calculation of 1/3"
- Better solutions are being considered
- This is tricky: Do we set a global variable? Do we require every math operation to specify precision? Do we store precision in each BigDecimal? Is that set from a global variable? Should we use macros to balance explicit precision and tidy code?
- Use environment variable
-
Add rounding module with
RoundingMode
enum- Used in new method: BigDecimal::with_scale_round
- Finally, you can truncate your decimal with the rounding you prefer!
- Will be coming to more methods, soon
-
Reimplement parsing from {32,64}-bit float values
- Use binary bits instead of formatting to string and parsing
- Already surprising users: #103
-
Bump Minimum Supported Rust Version from 1.34 to 1.43
- Was breaking a few test dependencies
- Able to do more at compile time
- Probably wont affect too many people?
-
Fix implementations of to_u128/to_i128 #101
- Default implementations cast values to 64 bit ints
-
Fix issue where underscores after the decimal counted towards total digit count (giving wrong exponent) #99
-
Fix case of panic during rounding #90
-
Add preliminary benchmarking code
- Unsatisfied with statistics: more work to be done with Criterion
- Eventually get some answers on how best to parse strings, and in what format should the digits be stored
-
Started using my crazy approach to unit testing