From 192b2383ac8ac06a9428d6e12c2003ef98625f24 Mon Sep 17 00:00:00 2001 From: Melissa Goad Date: Mon, 3 Aug 2020 14:02:13 -0500 Subject: [PATCH] LibJS: The Math.ceil() of a number between -1 and 0 should be -0, according to the spec. --- Libraries/LibJS/Runtime/MathObject.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Libraries/LibJS/Runtime/MathObject.cpp b/Libraries/LibJS/Runtime/MathObject.cpp index 830d5f4567..c166f49bad 100644 --- a/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Libraries/LibJS/Runtime/MathObject.cpp @@ -129,6 +129,9 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::ceil) return {}; if (number.is_nan()) return js_nan(); + auto number_double = number.as_double(); + if (number_double < 0 && number_double > -1) + return Value(-0.f); return Value(::ceil(number.as_double())); }