diff options
-rw-r--r-- | src/library.js | 6 | ||||
-rw-r--r-- | tests/runner.py | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/library.js b/src/library.js index 8a0b4993..a9f7c14a 100644 --- a/src/library.js +++ b/src/library.js @@ -286,7 +286,7 @@ var Library = { // Normalize it so wholePart is one digit. if (wholePart == '0') { - while (fractionPart[0] == '0') { + while (fractionPart.length && fractionPart[0] == '0') { exponent--; fractionPart = fractionPart.slice(1); } @@ -332,8 +332,8 @@ var Library = { fractionPart += '0'; } } - if (fractionPart.length && dropTrailingZeros) { - while (fractionPart[fractionPart.length - 1] == '0') { + if (dropTrailingZeros) { + while (fractionPart.length && fractionPart[fractionPart.length - 1] == '0') { fractionPart = fractionPart.slice(0, -1); } } diff --git a/tests/runner.py b/tests/runner.py index 414f5308..f4d163ac 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -601,11 +601,11 @@ if 'benchmark' not in sys.argv: #include <cmath> int main() { - printf("*%.2f,%.2f,%f*\\n", M_PI, -M_PI, 1/0.0); + printf("*%.2f,%.2f,%f,%f*\\n", M_PI, -M_PI, 1/0.0, -1/0.0); return 0; } ''' - self.do_test(src, '*3.14,-3.14,Infinity*') + self.do_test(src, '*3.14,-3.14,inf,-inf*') def test_getgep(self): # Generated code includes getelementptr (getelementptr, 0, 1), i.e., GEP as the first param to GEP |