-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bf9b5c
commit d7238b7
Showing
3 changed files
with
31 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
[package] | ||
name = "ratio" | ||
name = "int_ratio" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Yuekai Jia <[email protected]>"] | ||
description = "The type of ratios and related operations" | ||
description = "The type of ratios represented by two integers." | ||
license = "GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0" | ||
homepage = "https://github.com/arceos-org/arceos" | ||
repository = "https://github.com/arceos-org/ratio" | ||
documentation = "https://arceos-org.github.io/ratio" | ||
repository = "https://github.com/arceos-org/int_ratio" | ||
documentation = "https://docs.rs/int_ratio" | ||
keywords = ["ratio", "fraction", "integer", "approximation"] | ||
categories = ["mathematics"] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# int_ratio | ||
|
||
[](https://crates.io/crates/int_ratio) | ||
[](https://docs.rs/int_ratio) | ||
[](https://github.com/arceos-org/int_ratio/actions/workflows/ci.yml) | ||
|
||
The type of ratios and related operations. | ||
|
||
A **ratio** is the result of dividing two **integers**, i.e., the numerator and | ||
denominator. | ||
|
||
## Examples | ||
|
||
```rust | ||
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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters