lukewagner / polyfill-prototype-1

Experimental WebAssembly polyfill library and tools
Apache License 2.0
241 stars 42 forks source link

Big doubles lose precision #5

Open kripken opened 9 years ago

kripken commented 9 years ago

emscripten's tests/cases/bigdouble.ll emits (in asm1 mode)

function _main() {
 var $0 = 0.0, $vararg_buffer = 0, label = 0, sp = 0;
 sp = STACKTOP;
 STACKTOP = STACKTOP + 16|0;
 $vararg_buffer = sp;
 $0 = 4.0083367200179456E-292 * 1.0000000000000001E+300;
 HEAPF64[$vararg_buffer>>3] = $0;
 (_printf((8|0),($vararg_buffer|0))|0);
 STACKTOP = sp;return 0;
}

which is packed and unpacked into

function $ao(){
  var k=0,l=0,m=0,n=0.;
  m=$ab;
  $ab=$ab+16|0;
  k=m;
  n=4.00834e-292*1.e+300;
  h[k>>3]=n;
  $A(8,k|0)|0;
  $ab=m;
  return 0;
}

Note the first double has lost precision.

kripken commented 9 years ago

Also happens in test_closebitcasts on a smaller number, 1073741824.0 => 107374e4.