div-int
Rational numbers with a compile-time denominator.
This crate exports the DivInt
struct, which is a wrapper around integers that are
semantically divided by a compile-time constant. It's designed for embedded applications
where floats are sometimes represented as rational numbers with a known denominator.
Example
DivInt<u8, 50>
is a number that's internally stored as a u8, but is semantically a rational
number which value is the stored number divided by 50:
use DivInt;
let di: = from_numerator;
assert_eq!;
assert_eq!;
Crate features
The crate is no_std
by default. Optional features are:
serde
- adds serialization support.
License: MPL-2.0