fuzzy_fraction 0.1.2

Struct for approximated human-readable fraction representation..
Documentation
  • Coverage
  • 60%
    3 out of 5 items documented1 out of 1 items with examples
  • Size
  • Source code size: 11.19 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.59 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • p4ymak/fuzzy_fraction
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • p4ymak

Rust struct for approximated human-readable fraction representation.. No GCD or any dependencies involved..

use fuzzy_fraction::FuzzyFraction;

assert_eq!(FuzzyFraction::from_float(0.5).to_string(), "1/2");
assert_eq!(FuzzyFraction::from_float(-1.33).to_string(), "-1 1/3");

assert_eq!(FuzzyFraction::from_ints(1920, 1080).to_string(), "1 7/9");
assert_eq!(FuzzyFraction::from_ints(-10, 31).to_string(), "-1/3");

let ff = FuzzyFraction::from_ints(-1920, 1080);
assert_eq!(ff.to_string(), "-1 7/9");
assert_eq!(ff.ratio_fmt(), "16:9");