num-ord

This crate provides a numerically ordered wrapper type, NumOrd. This type implements the PartialOrd and PartialEq traits for all the possible combinations of built-in integer types, in a mathematically correct manner without overflows. Please refer to the the documentation for more information.

To start using num-ord add the following to your Cargo.toml:

toml [dependencies] num-ord = "0.1"

Example

```rust use num_ord::NumOrd;

let x = 3i64; let y = 3.5f64; asserteq!(x < (y as i64), false); // Incorrect. asserteq!(NumOrd(x) < NumOrd(y), true); // Correct.

let x = 9007199254740993i64; let y = 9007199254740992f64; asserteq!(format!("{}", y), "9007199254740992"); // No rounded constant trickery! asserteq!((x as f64) <= y, true); // Incorrect. assert_eq!(NumOrd(x) <= NumOrd(y), false); // Correct. ```

License

num-ord is released under the Zlib license, a permissive license. It is OSI and FSF approved and GPL compatible.