2 releases

0.1.1 Dec 20, 2024
0.1.0 Jul 17, 2024

#376 in Math

Download history 444/week @ 2024-11-22 359/week @ 2024-11-29 389/week @ 2024-12-06 314/week @ 2024-12-13 870/week @ 2024-12-20 663/week @ 2024-12-27 404/week @ 2025-01-03 294/week @ 2025-01-10 117/week @ 2025-01-17 76/week @ 2025-01-24 216/week @ 2025-01-31 351/week @ 2025-02-07 384/week @ 2025-02-14 257/week @ 2025-02-21 456/week @ 2025-02-28 1635/week @ 2025-03-07

2,775 downloads per month

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

8KB
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