Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix BigInt and Number comparison #1887

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions boa_engine/src/value/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,12 @@ impl JsValue {
if y.is_infinite() {
return Ok(y.is_sign_positive().into());
}
let n = if y.is_sign_negative() {
y.floor()
} else {
y.ceil()
};
(*x < JsBigInt::try_from(n).expect("invalid conversion to BigInt"))
.into()

if let Ok(y) = JsBigInt::try_from(y) {
return Ok((*x < y).into());
}

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

if let Ok(x) = JsBigInt::try_from(x) {
return Ok((x < *y).into());
}

(x < y.to_f64()).into()
}
},
}
Expand Down