fastnum v0.1.11 has landed!

51 points Money-Tale7082 5 comments

New release v0.1.11 of fastnum - fast, exact precision decimal numbers crate. It provides signed and unsigned exact precision decimal numbers suitable for financial calculations that require significant integral and fractional digits with no round-off errors (such as 0.1 + 0.2 ≠ 0.3).

Added

  • Implement exponential exp and binary exponential exp2 functions for decimals.
  • Implement logarithmic ln, log10, log2, log functions for decimals.
  • Implement sqrt, cbrt, and nth_root roots functions for decimals.
  • Refactor and extend pow to support non-integer exponents.
  • Implement base trigonometric functions: sin, cos, tan, sin_cos for decimals.
  • Implement inverse trigonometric functions: asin, acos, atan, atan2 for decimals.
  • Implement hyperbolic functions: sinh, cosh, tanh for decimals.
  • Implement inverse hyperbolic functions: asinh, acosh, atanh for decimals.
  • Implement hypotenuse calculation hypot function for decimals.
  • Introduce fused multiply-add mul_add operation without intermediate rounding.
  • Introduce transmute operation for N-to-M bit decimal conversion.
  • Add integer and unsigned integer conversion utilities (from_int, from_uint).
  • Implement num_traits::float::Float trait.

All methods are const, so you can calculate e^(x) or even sin(x) as constant in compile-time.

Changed

  • Improved arithmetic precision of approximated mathematical calculations due to the use of extra precision digits and the absence of intermediate rounding.
  • Overhauled mathematical constants. Add INEXACT flag and extra precision digits.
  • Mark some methods as inexact by design.
  • Micro-optimizations in rounding.
  • Inline optimization and better precision handling for mathematical rounding.
  • Re-implement recip method without division.
  • Improve test coverage for mathematical operations (e.g., sqrt, ln, exp).
  • Remove libm dependency for no-std environment.

Fixed

  • Corrected edge cases for float (f32/f64) from/to Decimal conversions.
  • Fix long rounding issues with improved context precision.
  • General code quality improvements and bug fixes, including better inexact flag handling.

Documentation

  • Expanded documentation for all major operations with examples.
  • Added comprehensive examples and descriptions to LIB.md.
  • Minor fixes.

Docs: https://docs.rs/fastnum/latest/fastnum/

GitHub: https://github.com/neogenie/fastnum

Reddit intro: https://www.reddit.com/r/rust/comments/1hk61om/announcing_a_new_fast_exact_precision_decimal/

Feedback on this here or on GitHub is welcome! Thanks!