aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parseTools.js3
-rwxr-xr-xtests/runner.py6
2 files changed, 6 insertions, 3 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;
diff --git a/tests/runner.py b/tests/runner.py
index 4b4b012a..d876d8f9 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1543,7 +1543,7 @@ Succeeded!
src = '''
#include <stdio.h>
#include <math.h>
- int main()
+ int main(int argc, char **argv)
{
float x = 1.234, y = 3.5, q = 0.00000001;
y *= 3;
@@ -1552,6 +1552,8 @@ Succeeded!
printf("%.2f, %.2f, %.2f, %.2f\\n", fmin(0.5, 3.3), fmin(NAN, 3.3), fmax(0.5, 3.3), fmax(NAN, 3.3));
+ printf("small: %.10f\\n", argc * 0.000001);
+
/*
// Rounding behavior
float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
@@ -1563,7 +1565,7 @@ Succeeded!
return 0;
}
'''
- self.do_run(src, '*1,10,10.5,1,1.2340,0.00*\n0.50, 3.30, 3.30, 3.30\n')
+ self.do_run(src, '*1,10,10.5,1,1.2340,0.00*\n0.50, 3.30, 3.30, 3.30\nsmall: 0.0000010000\n')
def test_isnan(self):
src = r'''