2 releases

0.1.1 Dec 20, 2024
0.1.0 Jul 17, 2024

#317 in Math

Download history 201/week @ 2024-10-29 123/week @ 2024-11-05 305/week @ 2024-11-12 532/week @ 2024-11-19 346/week @ 2024-11-26 429/week @ 2024-12-03 343/week @ 2024-12-10 645/week @ 2024-12-17 685/week @ 2024-12-24 501/week @ 2024-12-31 410/week @ 2025-01-07 175/week @ 2025-01-14 139/week @ 2025-01-21 44/week @ 2025-01-28 372/week @ 2025-02-04 408/week @ 2025-02-11

970 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