coerce rationals to floats before coercing floats to rationals.
@@ -484,7 +484,10 @@ fn integer_float_pair(n1: BigInt, n2: OrderedFloat<f64>) -> NumberPair {
}
fn float_rational_pair(n1: OrderedFloat<f64>, n2: Ratio<BigInt>) -> NumberPair {
- if let Some(r) = Ratio::from_float(n1.into_inner()) {
+ match (n2.numer().to_f64(), n2.denom().to_f64()) {
+ (Some(num), Some(denom)) =>
+ NumberPair::Float(n1, OrderedFloat(num / denom)),
+ _ => if let Some(r) = Ratio::from_float(n1.into_inner()) {
NumberPair::Rational(r, n2)
} else if n1.into_inner().is_sign_positive() {
NumberPair::Float(OrderedFloat(f64::infinity()),
@@ -494,6 +497,7 @@ fn float_rational_pair(n1: OrderedFloat<f64>, n2: Ratio<BigInt>) -> NumberPair {
OrderedFloat(f64::neg_infinity()))
}
}
+ }
fn from(n1: Number, n2: Number) -> NumberPair
{
