Skip to content

Releases: akubera/bigdecimal-rs

v0.4.3

17 Mar 23:10
Compare
Choose a tag to compare
  • Use exponential formatting (scientific-notation) if number of leading zeros is greater than 5
    • so 1234e-304 is formatted as 1.234e-301 rather than 0.00.....{300-zeros)....00123
    • Fixes "out of memory errors" when massive amounts of zeros would have been printed
  • 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')
  • Minor optimizations removing unnecessary clones in addition and multiplication

v0.4.2

16 Oct 07:44
Compare
Choose a tag to compare

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

13 Jul 04:09
Compare
Choose a tag to compare

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

07 Jul 04:01
Compare
Choose a tag to compare

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)
  • 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?
  • 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