summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-04-30 21:38:32 +0300
committerLinus Groh <mail@linusgroh.de>2022-04-30 21:35:16 +0200
commit0399239e3fd647330e84b00e461587eaca1ffc74 (patch)
tree928d96cce09d753be4fffb7266bc97667aa1264a
parent0083fb629bb85f2fe1b837205f0f2710bdb05f03 (diff)
downloadserenity-0399239e3fd647330e84b00e461587eaca1ffc74.zip
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
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index 5b10f0085a..50aed9af35 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -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;
}