Macro extended_rational::uratio
[−]
[src]
macro_rules! uratio { ( $ n : expr , $ d : expr ) => { ... }; ( $ n : expr ) => { ... }; }
A macro for creating a new unsigned rational using a given ratio or decimal
Floating-point conversions may be wrong due to small rounding errors.
Panics
On attempt to create negative rational. Doesn't panic in optimized builds.
Alternatives
uratio!(n, d)
is equivalent toratio!(n, d).try_unsigned()
uratio!(n)
is equivalent toratio!(n).try_unsigned()
Examples
let five_thirds = uratio!(5, 3); let seventeen = uratio!(17); assert_eq!(five_thirds, URational::new(5, 3)); assert_eq!(seventeen, URational::new(17, 1));