int_ratio

Crates.ioint_ratio
lib.rsint_ratio
version0.1.2
created_at2024-07-17 06:50:39.401171+00
updated_at2025-06-12 15:15:27.146327+00
descriptionThe type of ratios represented by two integers.
homepagehttps://github.com/arceos-org/arceos
repositoryhttps://github.com/arceos-org/int_ratio
max_upload_size
id1305883
size14,369
core (github:arceos-org:core)

documentation

https://docs.rs/int_ratio

README

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)
Commit count: 5

cargo fmt