mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibJS: Do not negate zero into negative zero in ToIntegerOrInfinity
When the input value was in the range of [-1, 0] we would incorrectly negate the resulting integer, resulting in -0 instead of the expected 0
This commit is contained in:
parent
0083fb629b
commit
0399239e3f
1 changed files with 1 additions and 1 deletions
|
@ -800,7 +800,7 @@ ThrowCompletionOr<double> Value::to_integer_or_infinity(GlobalObject& global_obj
|
|||
if (number.is_infinity())
|
||||
return number.as_double();
|
||||
auto integer = floor(fabs(number.as_double()));
|
||||
if (number.as_double() < 0)
|
||||
if (number.as_double() < 0 && integer != 0)
|
||||
integer = -integer;
|
||||
return integer;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue