From: notoria Date: Fri, 28 Feb 2025 07:00:00 +0000 (+0100) Subject: Fix conversion from float to rational X-Git-Tag: v0.10.0~65^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=4f3843742c2f500e768497cad74c0b4a5d627f3d;p=scryer-prolog.git Fix conversion from float to rational --- diff --git a/src/machine/arithmetic_ops.rs b/src/machine/arithmetic_ops.rs index eab7e708..43ea34c2 100644 --- a/src/machine/arithmetic_ops.rs +++ b/src/machine/arithmetic_ops.rs @@ -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();