diff options
author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-09-20 11:02:29 +0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-09-25 09:54:06 +0700 |
commit | afc3adaf66f05c7ef863dbb195e28f46e9ef33b9 (patch) | |
tree | 27895c29c2a69b963cc98724dcd2250d5291c59a /src | |
parent | 2ec8c7a23fbc1adee266a1e9bf8ac3f24daf3663 (diff) |
Don't rewrite multiplication by 0 as 0.
This isn't safe when floats are involved as -1 * 0 is -0, not 0.
Diffstat (limited to 'src')
-rw-r--r-- | src/parseTools.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index ddfb9d01..8ce83adf 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1499,7 +1499,9 @@ function getFastValue(a, op, b, type) { } if (op in MUL_DIV) { if (op == '*') { - if (a == 0 || b == 0) { + // We can't eliminate where a or b are 0 as that would break things for creating + // a negative 0. + if ((a == 0 || b == 0) && !(type in Runtime.FLOAT_TYPES)) { return '0'; } else if (a == 1) { return b; |