diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-01-23 15:10:47 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-01-23 15:10:47 -0800 |
commit | 7bcb06708962ca4bd04add9d1c148869931a1c94 (patch) | |
tree | f986c15e80afb26ac8075dc8a6293c6666ee4571 /src/parseTools.js | |
parent | 408def0b2f1f69bf25dc708942e4846076f7d664 (diff) |
fix asm float notation for numbers less than 1 in absolute value
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index e3b7ed3c..2f6cd6e8 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1008,7 +1008,8 @@ function makeVarDef(js) { function asmEnsureFloat(value, type) { // ensures that a float type has either 5.5 (clearly a float) or +5 (float due to asm coercion) if (!ASM_JS) return value; - if (type in Runtime.FLOAT_TYPES && isNumber(value) && value.toString().indexOf('.') < 0) { + // coerce if missing a '.', or if smaller than 1, so could be 1e-5 which has no . + if (type in Runtime.FLOAT_TYPES && isNumber(value) && (value.toString().indexOf('.') < 0 || Math.abs(value) < 1)) { return '(+(' + value + '))'; } else { return value; |