Improve toFixed function

Fixes #1367.
From now numbers are represented as binary floating-point which guarantees the expected operation of toFixed function.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2017-07-14 19:38:13 +02:00
committed by yichoi
parent 148f91c90d
commit ad608e30dc
4 changed files with 199 additions and 22 deletions
+7 -5
View File
@@ -31,14 +31,16 @@ assert((-Infinity).toFixed(0) === "-Infinity");
assert(NaN.toFixed(0) === "NaN");
assert((0.0).toFixed(0) === "0");
assert((0.0).toFixed(1) === "0.0");
assert((-0.0).toFixed(0) === "-0");
assert((-0.0).toFixed(1) === "-0.0");
assert((123456789012345678901.0).toFixed(20) === "123456789012345680000.00000000000000000000");
assert((-0.0).toFixed(0) === "0");
assert((-0.0).toFixed(1) === "0.0");
assert((123456789012345678901.0).toFixed(20) === "123456789012345683968.00000000000000000000");
assert((123.56).toFixed(NaN) === "124");
assert((123.56).toFixed(-0.9) === "124");
assert((0.095).toFixed(2) === "0.10");
//assert((0.995).toFixed(2) === "0.99");
//assert((9.995).toFixed(2) === "9.99");
assert((0.995).toFixed(2) === "0.99");
assert((9.995).toFixed(2) === "9.99");
assert((7.995).toFixed(2) === "8.00");
assert((8.995).toFixed(2) === "8.99");
assert((99.995).toFixed(2) === "100.00");
try {