2 releases

0.1.1 Dec 20, 2024
0.1.0 Jul 17, 2024

#222 in Math

Download history 263/week @ 2024-09-13 355/week @ 2024-09-20 163/week @ 2024-09-27 370/week @ 2024-10-04 1042/week @ 2024-10-11 988/week @ 2024-10-18 462/week @ 2024-10-25 95/week @ 2024-11-01 268/week @ 2024-11-08 433/week @ 2024-11-15 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 658/week @ 2024-12-27

2,360 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