LibJS: Check both the quotient and remainder for rounding negativity
Our BigInt implementation can store the negativity of the division result in either the quotient or the remainder. This is exposed by an upcoming prototype, which will reach this division with: -432000000000000 / 86400000000000000000000 Which has the BigInt division result: quotient = 0 remainder = -432000000000000 (Our old Temporal implementation also had this bug).
This commit is contained in:
parent
b319d45566
commit
abc6b679c3
Notes:
github-actions[bot]
2024-11-23 13:47:52 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/abc6b679c3a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2513 Reviewed-by: https://github.com/shannonbooth ✅
1 changed files with 1 additions and 1 deletions
|
@ -788,7 +788,7 @@ Crypto::SignedBigInteger round_number_to_increment(Crypto::SignedBigInteger cons
|
|||
Sign is_negative;
|
||||
|
||||
// 2. If quotient < 0, then
|
||||
if (division_result.quotient.is_negative()) {
|
||||
if (division_result.quotient.is_negative() || division_result.remainder.is_negative()) {
|
||||
// a. Let isNegative be NEGATIVE.
|
||||
is_negative = Sign::Negative;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue