2 releases

0.1.1 Dec 20, 2024
0.1.0 Jul 17, 2024

#316 in Math

Download history 380/week @ 2024-10-27 79/week @ 2024-11-03 274/week @ 2024-11-10 547/week @ 2024-11-17 337/week @ 2024-11-24 431/week @ 2024-12-01 367/week @ 2024-12-08 561/week @ 2024-12-15 633/week @ 2024-12-22 618/week @ 2024-12-29 441/week @ 2025-01-05 208/week @ 2025-01-12 132/week @ 2025-01-19 57/week @ 2025-01-26 350/week @ 2025-02-02 322/week @ 2025-02-09

867 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