| Crates.io | my_r_num |
| lib.rs | my_r_num |
| version | 0.1.1 |
| created_at | 2025-07-17 03:32:27.207246+00 |
| updated_at | 2025-07-17 05:43:04.674531+00 |
| description | A Rust numeric type library that supports automatic optimization for various integer/float types, special values (NaN, positive/negative infinity), and implements common arithmetic operations and type conversions. |
| homepage | |
| repository | https://github.com/gylove1994/my_r_num |
| max_upload_size | |
| id | 1757034 |
| size | 19,959 |
A Rust numeric type library that supports automatic optimization for various integer/float types, special values (NaN, positive/negative infinity), and implements common arithmetic operations and type conversions.
Add to your Cargo.toml:
[dependencies]
my_r_num = { path = "." }
use my_r_num::Number;
fn main() {
let a = Number::from(10i8);
let b = Number::from(3.14f64);
let c = Number::from(20000i16);
let d = Number::parse("inf").unwrap();
println!("a = {} (type: {})", a, a.type_name());
println!("b = {} (type: {})", b, b.type_name());
println!("c = {} (type: {})", c, c.type_name());
println!("d = {} (type: {})", d, d.type_name());
let mut x = a + c;
x += Number::from(5);
println!("x = {}", x);
let y = b * Number::from(2);
println!("y = {}", y);
// Special value operations
println!("d + a = {}", d + a);
println!("d - d = {}", d - d);
}
let n = Number::parse("32767").unwrap();
assert_eq!(n.type_name(), "Integer16");
let nan = Number::parse("nan").unwrap();
assert!(nan.is_nan());
Run all unit tests:
cargo test
Feel free to open an issue for suggestions or questions!