aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-25 16:02:35 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-25 16:02:35 -0700
commitc777166191bfef6d5ed3da760722ea9028983e6f (patch)
tree9356e7ec305547b5a93a6887015ab26ec5f65019 /src/parseTools.js
parent7cc79ee531f2c44e5cbf3d071b205924578acffb (diff)
properly apply fround to all float constants, even if they are fractions and look like doubles
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index a61b5035..8322fb74 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1178,9 +1178,10 @@ 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 (!isNumber(value)) return value;
+ if (FROUND && type === 'float') return 'Math_fround(' + value + ')';
// 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)) {
- if (FROUND && type === 'float') return 'Math_fround(' + value + ')';
+ if (type in Runtime.FLOAT_TYPES && (value.toString().indexOf('.') < 0 || Math.abs(value) < 1)) {
if (RUNNING_JS_OPTS) {
return '(+' + value + ')'; // JS optimizer will run, we must do +x, and it will be corrected later
} else {