fraction

[Rust] Lossless fractions and decimals; drop-in float replacement

APACHE-2.0 License

Downloads
11.8M
Stars
83
Committers
18
fraction - 0.15.3 Latest Release

Published by dnsl48 6 months ago

  • num crate min required version is now 0.4.2 (The one where ConstOne and ConstZero were introduced)
fraction - 0.15.2

Published by dnsl48 6 months ago

[0.15.2] - 2024-04-28

Added

  • GenericFraction ConstOne and ConstZero trait implementations (special thanks to Raimundo Saona, aka @saona-raimundo)
fraction - 0.15.1

Published by dnsl48 9 months ago

Added

  • "with-unicode" feature implementation to format (and parse) floats with Unicode characters (special thanks to @feefladder)
fraction - 0.15.0 / 2024-01-01

Published by dnsl48 10 months ago

Added

  • GenericFraction try_from/try_into implementations for primitive types (u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize, isize, f32, f64)
  • GenericFraction try_from/try_into implementations for BigInt/BigUint ("with-bigint" feature)
  • GenericDecimal try_from/try_into implementations for primitive types (u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize, isize, f32, f64)
  • GenericDecimal try_from/try_into implementations for BigInt/BigUint ("with-bigint" feature)
  • Tests for all GenericDecimal ops (overloadable operators - std::ops)

Changed

  • GenericDecimal ops (overloadable operators) refactoring. Each operator is now implemented separately in its own module, allowing decoupled code with its own optimisations and tests.

Fixed

  • PartialOrd will now reuse Ord implementation where possible (refactor to make clippy happier)
  • Fixed logic in sub_assign and checked_sub that could sometimes produce incorrect results for a couple of edge cases with a negative zero (-0) as an operand.
fraction - 0.14.0

Published by dnsl48 about 1 year ago

Added

  • approx module with "Approximate mathematical operations", fn sqrt (special thanks to @squ1dd13 for the contribution!)
  • with-approx feature, enabling the approx module
fraction - 0.13.1

Published by dnsl48 over 1 year ago

[0.13.1] - 2023-02-25

Added

  • Clippy hint to allow manual filtering in GenericFraction::to_i64 implementation
  • A couple of tests for floor/ceil functions

Fixed

  • ceil & floor incorrect behaviour for negative numbers (special thanks to Morris Hansing aka morri2)
fraction - 0.13.0

Published by dnsl48 almost 2 years ago

[0.13.0] - 2023-01-01

Changed

  • PartialCmp now compares NaN with the other values and returns it as the smallest possible value. Thus, NaN < -Inf.

Fixed

  • partial_cmp now behaves exactly the same as cmp (PartialOrd is now consistent with Ord).
    This fixes an issue introduced in 0.12.2 with the implementation of Ord,
    where Ord would behave differently from PartialOrd with NaN values.
    Special thanks to Hsingai Tigris Altaica aka DrAlta for fixing this.
fraction - 0.12.2

Published by dnsl48 almost 2 years ago

[0.12.2] - 2022-12-04

Added

  • Ord trait implementation for GenericFraction and GenericDecimal (special thanks to Hsingai Tigris Altaica aka DrAlta)
fraction -

Published by dnsl48 about 2 years ago

Added

  • Support to add castable values (e.g. f + 1u8, 1u8 will be transparently casted to Fraction with .into())
  • Support to sub castable values (e.g. f - 1u8, 1u8 will be transparently casted to Fraction with .into())
  • Support to div castable values (e.g. f / 1u8, 1u8 will be transparently casted to Fraction with .into())
  • Support to mul castable values (e.g. f * 1u8, 1u8 will be transparently casted to Fraction with .into())
  • Support to add_assign castable values (e.g. f += 1u8, 1u8 will be transparently casted to Fraction with .into())
  • Support to sub_assign castable values (e.g. f -= 1u8, 1u8 will be transparently casted to Fraction with .into())
  • Support to div_assign castable values (e.g. f /= 1u8, 1u8 will be transparently casted to Fraction with .into())
  • Support to mul_assign castable values (e.g. f *= 1u8, 1u8 will be transparently casted to Fraction with .into())

Changed

  • Refactoring of the fraction module. std::ops implementations moved into separate submodules.
  • generic::read_generic_integer performance improved for when target type matches source (~83% improvement, which is 5 times faster).
    As the result this can affect GenericFraction::from performance for non-float types.
  • From<(A, B)> implementation is migrated to GenericFraction::new_generic (~85% performance improvement and with no heap allocations, which is ~7 times faster).
fraction - 0.12.0

Published by dnsl48 about 2 years ago

See CHANGELOG.md for the details

fraction -

Published by dnsl48 about 2 years ago

fraction -

Published by dnsl48 over 2 years ago

fraction - 0.8.0

Published by dnsl48 almost 4 years ago