]> Repositorios git - scryer-prolog.git/commitdiff
Fix conversion from float to rational
authornotoria <[email protected]>
Fri, 28 Feb 2025 07:00:00 +0000 (08:00 +0100)
committernotoria <[email protected]>
Fri, 28 Feb 2025 07:00:00 +0000 (08:00 +0100)
src/machine/arithmetic_ops.rs

index eab7e7080102e62a184ac4b4669668b8fb0d23da..43ea34c24993735f4fac3bc26374385336805942 100644 (file)
@@ -534,7 +534,7 @@ pub fn rational_from_number(
     match n {
         Number::Fixnum(n) => Ok(arena_alloc!(Rational::from(n.get_num()), arena)),
         Number::Rational(r) => Ok(r),
-        Number::Float(OrderedFloat(f)) => match Rational::simplest_from_f64(f) {
+        Number::Float(OrderedFloat(f)) => match Rational::try_from(f).ok() {
             Some(r) => Ok(arena_alloc!(r, arena)),
             None => Err(Box::new(move |machine_st| {
                 let instantiation_error = machine_st.instantiation_error();