Fraction
Lossless drop-in replacement for floating types (f32, f64)
The documentation is available on docs.rs.
Features
- Drop in replacement for floats with the exception for NaN == NaN so that it's hashable
- It's hashable, so may be used as values in Sets and keys in dictionaries and hash maps
- Fraction type, representing floats as fractions
- Decimal type, based on Fraction type, represents floats as decimals
- DynaInt implements dinamically growing integer type that perfarms checked math and avoids stack overflows
- PostgreSQL integration for Numeric/Decimal type (with no extra memory allocations)
- Juniper integration for both fractions and decimals
- Generic integer conversions, such as
i8 -> u8
,usize -> u8
and so on - Lossless division with no allocations and infinite precision
Examples
Simple arithmetic
use Fraction;
Decimal
type D = Decimal;
let result = from / from;
assert_eq!;
Using as keys for a HashMap
use HashMap;
use Fraction;
Generic integer conversion
use ;
type F = ;
let fra = new_generic.unwrap;
assert_eq!;
Comparison
use Fraction;
Change Log
Look into the CHANGELOG.md file for details