diff --git a/boa_engine/src/bigint.rs b/boa_engine/src/bigint.rs index 029350cb9f..df113190f5 100644 --- a/boa_engine/src/bigint.rs +++ b/boa_engine/src/bigint.rs @@ -453,21 +453,15 @@ impl PartialEq for i32 { impl PartialEq for JsBigInt { #[inline] fn eq(&self, other: &f64) -> bool { - if other.fract() != 0.0 { - return false; - } - - self.inner.as_ref() == &RawBigInt::from(*other as i64) + other.fract().is_zero() + && RawBigInt::from_f64(*other).map_or(false, |bigint| self.inner.as_ref() == &bigint) } } impl PartialEq for f64 { #[inline] fn eq(&self, other: &JsBigInt) -> bool { - if self.fract() != 0.0 { - return false; - } - - &RawBigInt::from(*self as i64) == other.inner.as_ref() + self.fract().is_zero() + && RawBigInt::from_f64(*self).map_or(false, |bigint| other.inner.as_ref() == &bigint) } }