4 releases

0.3.2 Apr 2, 2026
0.1.2 Jun 12, 2025
0.1.1 Dec 20, 2024
0.1.0 Jul 17, 2024

#195 in Math

Download history 705/week @ 2026-01-23 830/week @ 2026-01-30 1835/week @ 2026-02-06 264/week @ 2026-02-13 1125/week @ 2026-02-20 1487/week @ 2026-02-27 1672/week @ 2026-03-06 1459/week @ 2026-03-13 1611/week @ 2026-03-20 2111/week @ 2026-03-27 1242/week @ 2026-04-03 1193/week @ 2026-04-10 1667/week @ 2026-04-17 1432/week @ 2026-04-24 866/week @ 2026-05-01 1130/week @ 2026-05-08

5,292 downloads per month
Used in 51 crates (4 directly)

GPL-3.0-or-later OR Apache-2…

9KB
112 lines

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)

No runtime deps