Skip to content

kern-crates/int_ratio

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%