Fix Math.trunc(x) if -1 < x < 0 (#3445)
Math.trunc(x) should be -0.0 if -1 < x < 0 (ES2015 20.2.2.35). The problem was that -0 isn't -0.0, but +0.0 in C. There were a test case for it, but it was incorrect, because +0.0 === -0.0 in JS. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
df6995d0f6
commit
fb4b18a515
@@ -177,12 +177,12 @@ ecma_builtin_math_object_trunc (ecma_number_t arg)
|
||||
|
||||
if ((arg > 0) && (arg < 1))
|
||||
{
|
||||
return (ecma_number_t) 0;
|
||||
return (ecma_number_t) 0.0;
|
||||
}
|
||||
|
||||
if ((arg < 0) && (arg > -1))
|
||||
{
|
||||
return (ecma_number_t) -0;
|
||||
return (ecma_number_t) -0.0;
|
||||
}
|
||||
|
||||
return (ecma_number_t) arg - fmod (arg, 1);
|
||||
|
||||
Reference in New Issue
Block a user