aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-24 21:20:47 -0700
committeralon@honor <none@none>2010-09-24 21:20:47 -0700
commit597dde09b5788dc2728feb295983ae4c02b10dbb (patch)
treeb12ca12810577a11fdd90cbdc75a3501c469388c /src/parseTools.js
parent05b2fafe901cf658c9f1acb80757f06453aacc62 (diff)
Infinity and NaN
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js7
1 files changed, 4 insertions, 3 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();
}