Browse Source

Fix `PartialEq` for `JsBigInt` and `f64` (#2461)

This Pull Request changes the following:

- Use the `BigInt::from_f64` function when checking `JsBigInt` and `f64` for eqality.
pull/2464/head
raskad 2 years ago
parent
commit
7971d4c197
  1. 14
      boa_engine/src/bigint.rs

14
boa_engine/src/bigint.rs

@ -453,21 +453,15 @@ impl PartialEq<JsBigInt> for i32 {
impl PartialEq<f64> 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<JsBigInt> 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)
}
}

Loading…
Cancel
Save