mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
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
|
|
@ -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…
Reference in New Issue
Block a user