int_ratio 0.1.2

The type of ratios represented by two integers.
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented5 out of 7 items with examples
  • Size
  • Source code size: 13.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 874.43 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • arceos-org/int_ratio
    0 4 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • equation314 github:arceos-org:core

int_ratio

Crates.io Docs.rs CI

The type of ratios and related operations.

A ratio is the result of dividing two integers, i.e., the numerator and denominator.

Examples

use int_ratio::Ratio;

let ratio = Ratio::new(1, 3); // 1 / 3
assert_eq!(ratio.mul_trunc(20), 6); // trunc(20 * 1 / 3) = trunc(6.66..) = 6
assert_eq!(ratio.mul_round(20), 7); // round(20 * 1 / 3) = round(6.66..) = 7
println!("{:?}", ratio); // Ratio(1/3 ~= 1431655765/4294967296)