diff options
-rw-r--r-- | src/parseTools.js | 7 | ||||
-rw-r--r-- | tests/runner.py | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index f0ac834c..cdd20e2f 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -327,15 +327,16 @@ function IEEEUnHex(stringy) { var a = eval('0x' + stringy.substr(0, 8)); // top half var b = eval('0x' + stringy.substr(8)); // bottom half var e = a >> ((52 - 32) & 0x7ff); // exponent + a = a & 0xfffff; if (e === 0x7ff) { if (a == 0 && b == 0) { - return Infinity; + return 'Infinity'; } else { - return NaN; + return 'NaN'; } } e -= 1023; // offset - var absolute = ((((a & 0xfffff | 0x100000) * 1.0) / Math.pow(2,52-32)) * Math.pow(2, e)) + (((b * 1.0) / Math.pow(2, 52)) * Math.pow(2, e)); + var absolute = ((((a | 0x100000) * 1.0) / Math.pow(2,52-32)) * Math.pow(2, e)) + (((b * 1.0) / Math.pow(2, 52)) * Math.pow(2, e)); return (absolute * (neg ? -1 : 1)).toString(); } diff --git a/tests/runner.py b/tests/runner.py index 1149bfd9..519494ed 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -153,11 +153,11 @@ class T(unittest.TestCase): #include <cmath> int main() { - printf("*%.2f,%.2f*\\n", M_PI, -M_PI); + printf("*%.2f,%.2f,%f*\\n", M_PI, -M_PI, 1/0.0); return 0; } ''' - self.do_test(src, '*3.14,-3.14*') + self.do_test(src, '*3.14,-3.14,Infinity*') def test_if(self): src = ''' |