Module malachite_q::conversion::from_primitive_float
source · [−]Expand description
Implementations of the From
trait for converting a primitive float to a
Rational
.
from
use malachite_q::Rational;
assert_eq!(Rational::from(0.0), 0);
assert_eq!(Rational::from(1.5).to_string(), "3/2");
assert_eq!(Rational::from(-1.5).to_string(), "-3/2");
assert_eq!(Rational::from(0.1f32).to_string(), "13421773/134217728");