Skip to content

Commit c9823a4

Browse files
committedJun 2, 2014
fix very large doubles; fixes #2392
1 parent 2d819db commit c9823a4

6 files changed

+10
-8
lines changed
 

‎tests/core/test_floatvars.in

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ int main(int argc, char **argv) {
1515

1616
printf("small: %.10f\n", argc * 0.000001);
1717

18-
/*
19-
// Rounding behavior
20-
float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
21-
double ds[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
22-
for (int i = 0; i < 6; i++)
23-
printf("*int(%.2f)=%d,%d*\n", fs[i], int(fs[i]), int(ds[i]));
24-
*/
18+
double d = 1.12345678901234567890123e21;
19+
printf("double: %f\n", d);
2520

2621
return 0;
2722
}

‎tests/core/test_floatvars.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*1,10,10.5,1,1.2340,0.00*
22
0.50, 3.30, 3.30, 3.30
33
small: 0.0000010000
4+
double: 1.1234567890123457e+21

‎tests/test_core.py

+2
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,8 @@ def test_bitfields(self):
797797
self.do_run_from_file(src, output)
798798

799799
def test_floatvars(self):
800+
if self.run_name == 'slow2asm': return self.skip('FIXME in slow2asm')
801+
800802
test_path = path_from_root('tests', 'core', 'test_floatvars')
801803
src, output = (test_path + s for s in ('.in', '.out'))
802804

‎tools/js-optimizer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5165,7 +5165,9 @@ function prepDotZero(ast) {
51655165
function fixDotZero(js) {
51665166
return js.replace(/DOT\$ZERO\(([-+]?(0x)?[0-9a-f]*\.?[0-9]+([eE][-+]?[0-9]+)?)\)/g, function(m, num) {
51675167
if (num.substr(0, 2) === '0x' || num.substr(0, 3) === '-0x') {
5168-
return eval(num) + '.0';
5168+
var ret = eval(num).toString();
5169+
if (ret.indexOf('.') < 0) return ret + '.0';
5170+
return ret;
51695171
}
51705172
if (num.indexOf('.') >= 0) return num;
51715173
var e = num.indexOf('e');

‎tools/test-js-optimizer-asm-last-output.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function finall(x) {
3030
a = -999999984306749400.0;
3131
a = -999999984306749400.0;
3232
a = -0xde0b6b000000000;
33+
a = 1.1234567890123457e+21;
3334
f(g() | 0);
3435
return 12.0e10;
3536
}

‎tools/test-js-optimizer-asm-last.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function finall(x) {
3030
a = +-0xde0b6b000000000;
3131
a = -+0xde0b6b000000000;
3232
a = -0xde0b6b000000000;
33+
a = +0x3ce7184d470dd60000;
3334
f(g() & -1);
3435
return +12e10;
3536
}

0 commit comments

Comments
 (0)
Please sign in to comment.