Skip to content

Commit

Permalink
Fix BigInt and Number comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Mar 14, 2022
1 parent 48f23b3 commit ebd7fd9
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions boa_engine/src/value/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,19 @@ impl JsValue {
if y.is_infinite() {
return Ok(y.is_sign_positive().into());
}
let n = if y.is_sign_negative() {
y.floor()

if x.to_f64() >= y {
false
} else {
y.ceil()
};
(*x < JsBigInt::try_from(n).expect("invalid conversion to BigInt"))
.into()
let n = if y.is_sign_negative() {
y.floor()
} else {
y.ceil()
};

*x < JsBigInt::try_from(n).expect("invalid conversion to BigInt")
}
.into()
}
(Numeric::Number(x), Numeric::BigInt(ref y)) => {
if x.is_nan() {
Expand All @@ -551,13 +557,19 @@ impl JsValue {
if x.is_infinite() {
return Ok(x.is_sign_negative().into());
}
let n = if x.is_sign_negative() {
x.floor()

if x >= y.to_f64() {
false
} else {
x.ceil()
};
(JsBigInt::try_from(n).expect("invalid conversion to BigInt") < *y)
.into()
let n = if x.is_sign_negative() {
x.floor()
} else {
x.ceil()
};

JsBigInt::try_from(n).expect("invalid conversion to BigInt") < *y
}
.into()
}
},
}
Expand Down

0 comments on commit ebd7fd9

Please sign in to comment.