PackageTrack
Sign in Get early access

fraction

Lossless fractions and decimals; drop-in float replacement

0.17.0 80M downloads/mo #910 most downloaded on crates.io dnsl48/fraction

What this package is like to depend on

Last release today

22 Aug 2026

Ships unpredictably

gaps range from 2 weeks to 1.9 years

Nearly every release is documented

notes for 38 of 38 stable releases

1 version withdrawn

withdrawn after publishing

11 years old

39 releases · first in 2016

3 releases in the last 12 months

see the full history below

Release timeline

39 releases · Jan 2016 to Aug 2026
2017 2018 2019 2020 2021 2022 2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 39
  1. 0.17.0 22 Aug 2026
    Release notes

    [0.17.0] - 2026-08-23

    Changed

    • Breaking: GenericFraction::<T>::from_unicode_str now requires T: CheckedAdd + CheckedMul. Custom
      backing types must provide both operations for mixed-component combination; standard bounded, big-integer, and
      dynamic backings satisfy these bounds.
    • Breaking: Numeric-component forms in ordinary Fraction/Decimal, Unicode, GenericFraction radix, and
      Juniper parsing reject component-local signs while retaining one sign for the complete value. Fraction Juniper
      input still requires its explicit outer sign; Decimal Juniper input delegates to ordinary Decimal grammar.
      From<&str> for GenericDecimal continues to map parse failures to NaN.
    • Breaking: GenericFraction changes its Num::FromStrRadixErr associated type from ParseRatioError to
      ParseError. Its fraction-only numerator/denominator grammar is unchanged, zero denominators return
      ParseError::ZeroDenominator, and direct Ratio parsing still uses ParseRatioError.
    • Breaking: ParseError is now non-exhaustive; downstream matches must include a wildcard arm.
    • Breaking: DynaInt changes its Num::FromStrRadixErr associated type to ParseError; malformed inputs and
      values that neither backing type can represent return ParseError::ParseIntError.

    Fixed

    • Unicode mixed-number parsing now returns ParseIntError when the raw combined numerator
      (whole × denominator + numerator) is not representable by the backing integer type, instead of panicking in
      debug builds or wrapping in release builds.
    • Signed backing types no longer allow component-local signs to create negative magnitudes inside stored ratios;
      component-local signed-minimum inputs now fail deterministically.
    • GenericFraction and DynaInt radix parsing no longer panic for bases outside 2 through 36; they return
      ParseError::UnsupportedBase instead of forwarding invalid bases to their backing integer implementations.
    Open source →
    Release notes

    Changed

    • Breaking: GenericFraction::<T>::from_unicode_str now requires T: CheckedAdd + CheckedMul. Custom backing types must provide both operations for mixed-component combination; standard bounded, big-integer, and dynamic backings satisfy these bounds.
    • Breaking: Numeric-component forms in ordinary Fraction/Decimal, Unicode, GenericFraction radix, and Juniper parsing reject component-local signs while retaining one sign for the complete value. Fraction Juniper input still requires its explicit outer sign; Decimal Juniper input delegates to ordinary Decimal grammar. From<&str> for GenericDecimal continues to map parse failures to NaN.
    • Breaking: GenericFraction changes its Num::FromStrRadixErr associated type from ParseRatioError to ParseError. Its fraction-only numerator/denominator grammar is unchanged, zero denominators return ParseError::ZeroDenominator, and direct Ratio parsing still uses ParseRatioError.
    • Breaking: ParseError is now non-exhaustive; downstream matches must include a wildcard arm.
    • Breaking: DynaInt changes its Num::FromStrRadixErr associated type to ParseError; malformed inputs and values that neither backing type can represent return ParseError::ParseIntError.

    Fixed

    • Unicode mixed-number parsing now returns ParseIntError when the raw combined numerator (whole × denominator + numerator) is not representable by the backing integer type, instead of panicking in debug builds or wrapping in release builds.
    • Signed backing types no longer allow component-local signs to create negative magnitudes inside stored ratios; component-local signed-minimum inputs now fail deterministically.
    • GenericFraction and DynaInt radix parsing no longer panic for bases outside 2 through 36; they return ParseError::UnsupportedBase instead of forwarding invalid bases to their backing integer implementations.
    Open source →
  2. 0.16.0 09 Aug 2026
    Release notes

    [0.16.0] - 2026-08-09

    Changed

    • Replaced optional lazy_static usage with std::sync::OnceLock and num-bigint constants for approximation accuracy multipliers (special thanks to Expyron for the std::sync::OnceLock patch).
    • Breaking: Rust 1.70 is now the minimum supported Rust version (MSRV).

    Fixed

    • Fraction and Decimal parsing now routes zero-denominator inputs to signed infinity or NaN (including optional Unicode from_unicode_str) rather than panicking.
    • Restored Decimal Ord/PartialOrd/Eq/Hash consistency by comparing each value using its stored precision, including truncation and canonical zero handling (-0, -0.9@p0, -0.04@p1), so ordered and hashed collections now agree.
    • Added PostgreSQL NUMERIC infinity round-trip support for both Fraction and Decimal, encoding/decoding ±Infinity using 0xD000/0xF000 markers and documenting PostgreSQL 14+/unconstrained NUMERIC requirements.
    Open source →
    Release notes

    Changed

    • Replaced optional lazy_static usage with std::sync::OnceLock and num-bigint constants for approximation accuracy multipliers (special thanks to Expyron for the std::sync::OnceLock patch).
    • Breaking: Rust 1.70 is now the minimum supported Rust version (MSRV).

    Fixed

    • Fraction and Decimal parsing now routes zero-denominator inputs to signed infinity or NaN (including optional Unicode from_unicode_str) rather than panicking.
    • Restored Decimal Ord/PartialOrd/Eq/Hash consistency by comparing each value using its stored precision, including truncation and canonical zero handling (-0, -0.9@p0, -0.04@p1), so ordered and hashed collections now agree.
    • Added PostgreSQL NUMERIC infinity round-trip support for both Fraction and Decimal, encoding/decoding ±Infinity using 0xD000/0xF000 markers and documenting PostgreSQL 14+/unconstrained NUMERIC requirements.
    Open source →
  3. 0.15.4 21 Apr 2026
    Release notes

    What's Changed

    New Contributors

    Full Changelog: 0.15.3...0.15.4

    Open source →
    Release notes

    Added

    • from_fraction_with_precision helper

    Changed

    • Captured the crate edition explicitly in Cargo.toml as edition = "2015".
    • num crate min required version is now 0.4.3

    Fixed

    • Tidy-up deprecation and clippy warnings, plus small docs/licence metadata fixes.
    • Corrected the crate-level Unicode example/docs so default cargo test no longer fails without with-unicode.
    Open source →
  4. 0.15.3 12 May 2024
    Release notes
    • num crate min required version is now 0.4.2 (The one where ConstOne and ConstZero were introduced)
    Open source →
    Release notes

    Changed

    • num crate min required version is now 0.4.2
    Open source →
  5. 0.15.2 27 Apr 2024 withdrawn
    Release notes

    [0.15.2] - 2024-04-28

    Added

    • GenericFraction ConstOne and ConstZero trait implementations (special thanks to Raimundo Saona, aka @saona-raimundo)
    Open source →
    Release notes

    Added

    • GenericFraction ConstOne and ConstZero trait implementations (special thanks to Raimundo Saona, aka @saona-raimundo)
    Open source →
  6. 0.15.1 11 Feb 2024
    Release notes

    Added

    • "with-unicode" feature implementation to format (and parse) floats with Unicode characters (special thanks to @feefladder)
    Open source →
    Release notes

    Added

    • "with-unicode" feature implementation to format (and parse) floats with Unicode characters (special thanks to @feefladder)
    Open source →
  7. 0.15.0 01 Jan 2024
    Release notes

    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.
    Open source →
  8. 0.14.0 27 Sep 2023
    Release notes

    Added

    • approx module with "Approximate mathematical operations", fn sqrt (special thanks to @squ1dd13 for the contribution!)
    • with-approx feature, enabling the approx module
    Open source →
    Release notes

    Added

    • approx module with "Approximate mathematical operations", fn sqrt (special thanks to @squ1dd13 for the contribution!)
    • with-approx feature, enabling the approx module
    Open source →
  9. 0.13.1 24 Feb 2023
    Release notes

    [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)
    Open source →
    Release notes

    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)
    Open source →
  10. 0.13.0 01 Jan 2023
    Release notes

    [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.
    Open source →
    Release notes

    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.
    Open source →
  11. 0.12.2 04 Dec 2022
    Release notes

    Added

    • Ord trait implementation for GenericFraction and GenericDecimal (special thanks to Hsingai Tigris Altaica aka DrAlta)
    Open source →
  12. 0.12.1 19 Oct 2022
    Release notes

    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).
    Open source →
  13. 0.12.0 13 Oct 2022
    Release notes

    Changed

    • num version 0.4 is now required (0.2, 0.3 are no longer supported)
    • Multiple functions made const in GenericFraction, GenericDecimal and fraction::display::Format Special thanks to Stijn Frishert (aka stijnfrishert).

    Deprecated

    • fn decimal::GenericDecimal::apply_ref is deprecated.

    Removed

    • Removed deprecated fn decimal::GenericDecimal::from_decimal_str. Use FromStr::from_str instead.
    • Removed deprecated fn fraction::GenericFraction::from_decimal_str. Use FromStr::from_str instead.
    • Removed deprecated fn fraction::GenericFraction::format_as_decimal. Use format!(\"{:.1$}\", fraction, precision) instead.
    • Removed deprecated fn fraction::GenericFraction::new_raw_neg. Use new_raw_signed instead.
    Open source →
  14. 0.11.2 17 Sep 2022
    Release notes
    • DynaInt now implements serde Serialize & Unserialize (Thanks to Richard Davies aka @optevo for the contribution!)
    Open source →
  15. 0.11.1 07 Aug 2022
    Release notes

    Fixed

    • Fraction::from_str trims trailing zeroes before calculating denom (Thanks to @khigia for the contribution!)
    Open source →
  16. 0.11.0 18 Jun 2022
    Release notes

    Changed

    • num dependency versions extended from 0.2 to >=0.2,<5 (Thanks to Joel Natividad aka jqnatividad for the contribution!)
    • lazy_static dependency versions extended from 1.1 to 1
    Open source →
  17. 0.10.0 06 Feb 2022
    Release notes

    Added

    • std::str::FromStr trait implementation for GenericFraction and GenericDecimal Special thanks to Scott Wilson for the contribution
    • Deprecated GenericFraction::from_decimal_str and GenericDecimal::from_decimal_str in favour of of std::str::FromStr
    Open source →
  18. 0.9.0 21 Aug 2021
    Release notes

    Added

    • Default trait implementation for GenericFraction and GenericDecimal
    • postgres-types: ^0.2 and bytes: 1 are new optional dependencies (feature: with-postgres-support)
    • GenericFraction::new_raw_signed constructor

    Changed

    • Juniper supported version upgraded from 0.11 to 0.15
    • Postgres supported version upgraded from 0.15 to 0.19 (might be down to 0.16, but untested).

    Removed

    • postgres crate is not a dependency any longer
    • Deprecated fn GenericFraction::format_as_decimal is removed
    Open source →
  19. 0.8.0 16 Dec 2020
    Release notes

    Changed

    • More efficient f32/f64 conversion to Fractions and Decimals (up to 10 times faster and not using memory allocation anymore) Special thanks to Christopher Rabotin for the contribution!
    Open source →
  20. 0.7.0 04 Dec 2020
    Release notes

    Added

    • fraction::display::Format implements Clone trait (becomes cloneable)
    • fraction::Sign implements PartialOrd and Ord traits (becomes orderable)
    • GenericDecimal::calc_precision max_precision optional argument to limit the calculation

    Changed

    • Decimal::from_fraction now limits precision calculation to 255
    • rustfmt for the whole codebase
    • small readability refactoring for some methods
    Open source →
  21. 0.6.3 06 May 2020
    Release notes

    Added

    • std::iter::{Sum, Product} implemented for GenericFraction and GenericDecimal
    Open source →
  22. 0.6.2 19 May 2019
    Release notes

    Addad

    • std::error::Error implemented for error::ParseError
    Open source →
  23. 0.6.1 28 Mar 2019
    Release notes

    Added

    • dynaint, Into<BigUint> implementation
    • fraction, GenericFraction::into_fraction<I> method implementation
    Open source →
  24. 0.6.0 04 Feb 2019
    Release notes

    Added

    • division::divide_to_callback implementation. Some other functions refactored to be using it internally
    • fraction::display module implementation, Fraction ::std::fmt::Display implementation supporting all the features of the std::fmt::Formatter
    • Decimal ::std::fmt::Display implementation supporting all the features of the std::fmt::Formatter

    Changed

    • Juniper updated to 0.11
    • GenericFraction::format_as_decimal is now deprecated. Use format! macro instead, or division module if you need more control
    • division module functions signatures now have flags for trailing zeroes

    Removed

    • Deprecated functions
    Open source →
  25. 0.5.0 25 Nov 2018
    Release notes

    Changed

    • Division module API; functions to return division state for later reuse (remainder and divisor)
    Open source →
  26. 0.4.1 18 Oct 2018
    Release notes

    Added

    • DynaInt, initial std::fmt::Display implementation
    Open source →
  27. 0.4.0 09 Oct 2018
    Release notes

    Bugs

    • Hash implementation for GenericFraction now returns equal hashes for negative and positive zeroes

    Added

    • Lossless division, fraction decimal representation with infinite precision
    • Decimal type, built on top of Fraction
    • PostgreSQL integration
    • Juniper integration
    • Types with dynamic growth into heap on overflow
    • Generic integer conversions (usize -> i8, i8 -> u8, etc)
    • Examples and documentation for new features
    • Re-exporting the bunch of num traits so that the library can be used without explicit dependency on num

    Refactoring

    • The lib has been split into modules with separate features

    Modules

    • convert module with traits for optimistic convesion
    • decimal module with GenericDecimal implementation, Juniper and PostgreSQL integration for it
    • division module with lossless infinite division implementation without memory allocation
    • dynaint module with DynaInt type implementation (dynamically growing integer)
    • error module with shared library error types
    • fraction module with GenericFraction implementation, Juniper and PostgreSQL integration for it
    • generic module with GenericInteger trait implementation, generic integer types conversion
    • prelude module with some predefined type aliases such as Fraction and Decimal
    • tests module with some tests

    Features

    • with-bigint (default), integration with num::{BigInt, BigUint} types
    • with-decimal (default), GenericDecimal type implementation
    • with-dynaint (default), DynaInt type implementation
    • with-juniper-support, Juniper 0.10 integration
    • with-postgres-support, Postgres 0.15 integration

    Changes

    • GenericFraction redundant methods deprecated: new_nan, new_inf, new_inf_neg, into_big, format_as_float
    Open source →
  28. 0.3.7 09 Nov 2017
    Release notes

    Bugs

    • Fix comparisons with negative numbers
    Open source →
  29. 0.3.6 26 Jul 2017
    Release notes

    Bugs

    • T in GenericFraction<T> is Clone + Integer from now onwards (thanks to Taryn Hill aka Phrohdoh)
    Open source →
  30. 0.3.5 15 Apr 2017
    Release notes

    Changed

    • num package dependency version updated from "0.1.36" to "0.1.37"
    Open source →
  31. 0.3.4 10 Dec 2016
    Release notes

    Bugs

    • fn _new now returns NaN for 0/0 (was Infinity before)
    • fn sign now returns values for GenericFraction::Infinite values too
    • fn neg_zero now returns zero with negative sign (was positive before)
    • fn recip now handles zero values gracefully (does not panic, returns Infinity)

    Added

    • Lots of documentation
    Open source →
  32. 0.3.3 17 Nov 2016
    Release notes

    Refactoring

    • More efficient implementation of From<[unsigned ints]>
    • More generic implementation of From<BigInt>
    Open source →
  33. 0.3.2 12 Nov 2016
    Release notes

    Refactoring

    • Zero::is_zero to be used everywhere in math, rather than making new zero vals + comparing with them

    Added

    • fn new_nan constructor
    • fn new_inf constructor
    • fn new_inf_neg constructor
    Open source →
  34. 0.3.1 11 Nov 2016
    Release notes

    Added

    • fn format_as_float implemented for GenericFraction<T> (it was only available for BigFraction before)

    Changed

    • Into<T> to be used in bounds rather than From<N>, since it's more flexible (thanks to Alexander Altman for the patch)
    • number of bug fixes within fn format_as_float + test coverage
    Open source →
  35. 0.3.0 07 Nov 2016
    Release notes

    Added

    • From<(N, D)> generic implementation (through std::fmt::Display)

    Changed

    • GenericFraction<T> copy semantic to be applied only when T: Clone
    • GenericFraction impl, constructors refactoring (new, new_raw)
    • num upgraded up to 0.1.36 (from 0.1.34)

    Removed

    • fn new does not perform type casting through fmt::Display anymore (that functionality moved out as From<(N, D)>)
    Open source →
  36. 0.2.2 17 Sep 2016
    Release notes

    Added

    • impl From<num::BigInt> for BigFraction
    • impl From<num::BigUint> for BigFraction
    Open source →
  37. 0.2.1 27 Aug 2016
    Release notes

    Changed

    • Package description has been changed
    Open source →
  38. 0.2.0 27 Aug 2016
    Release notes

    Added

    • num crate is a dependency now
    • GenericFraction<T> implemented upon num::Ratio<T>
    • BigFraction implementation based on num::BigRational (using heap)
    • num::traits::Bounded trait implemented
    • fn min_positive_value implemented
    • num::traits::ToPrimitive trait implemented
    • num::traits::Signed trait implemented
    • From<f64> trait implementation now relies on format! macro instead of f64::fract
    • BigFraction struct using num::BigUint
    • fn format_as_float for BigFraction has been implemented

    Changed

    • The codebase has been rewritten and the license has been changed from LGPL-3 to MIT/Apache2 dual
    • no more convertions into INFINITY on arithmetic overflows
    • fn to_f64 now returns Option<f64> instead of f64 (num::trait::ToPrimitive implementation)
    • From trait implementation uses fmt::Display from now on

    Removed

    • fn unpack removed
    • std::cmp::Ord implementation removed in regard to NaN values
    Open source →
  39. 0.1.0 24 Jan 2016
    Release notes

    Added

    • Basic implementation
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive