Issue metadata
Sign in to add a comment
|
floating point inaccuracy with mod
Reported by
8998...@gmail.com,
Jan 16 2017
|
||||||||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 Steps to reproduce the problem: Execute the next line in JavaScript and for some people, it is NaN: 1.7976931348623158e308 % 1.698093170258119e-130 Proof: http://i.imgur.com/wGe5EJe.png What is the expected behavior? I am not sure what the correct result should be, but certainly not NaN. In Firefox, a friend's Chrome browser and C, it is 6.124987715625227e-132: #include <math.h> #include <stdio.h> int main(){ printf("%g\n", fmod(1.7976931348623158e308, 1.698093170258119e-130)); printf("%g\n", remainder(1.7976931348623158e308, 1.698093170258119e-130)); return 0; } What went wrong? The result in Chrome is NaN. Did this work before? N/A Chrome version: 55.0.2883.87 Channel: stable OS Version: 6.3 Flash Version: Shockwave Flash 24.0 r0 1.7976931348623158e308 is Number.MAX_VALUE. The value of 1.698093170258119e-130 seems to be crucial down to the last bit. It does not seem to be a floating point parsing issue since it also happens when the number is constructed from bytes: var view = new DataView(new ArrayBuffer(8)) view.setUint32(0, 0x24fe21ff) view.setUint32(4, 0xcc3a9351) var x = view.getFloat64(0) console.log("Number is 1.698093170258119e-130 as expected:", x) console.log("This should not be NaN, but it is:", Number.MAX_VALUE % x)
,
Jan 16 2017
,
Jan 16 2017
I could reproduce the bug by compiling the C code with an online Visual Studio compiler instead of gcc: http://rextester.com/CUXF63188 However, I am unable to report the bug there since their webform is garbage and does not let me, so if this issue should be fixed, someone else has to report it to Microsoft.
,
Jan 18 2017
Tested this issue on windows 10 with chrome version #55.0.2883.87
On pasting below code into the console, observed the output as "6.124987715625227e-132" but not as Nan
code
-----
var view = new DataView(new ArrayBuffer(8))
view.setUint32(0, 0x24fe21ff)
view.setUint32(4, 0xcc3a9351)
var x = view.getFloat64(0)
console.log("Number is 1.698093170258119e-130 as expected:", x)
console.log("This should not be NaN, but it is:", Number.MAX_VALUE % x)
Attaching the screen-cast for your reference, could you please look into it and let us know your observations.
,
Feb 6 2017
Just to confirm: If you build it yourself with VS, you get this error?
,
Feb 9 2017
to hablich@chromium.org: I am referring to the C code in the initial post that is also visible if you click the link in my previous comment (same link again): http://rextester.com/CUXF63188 If you click on the button labeled "Run it", you will see that the result is "-nan(ind)", which is wrong. A friend was able to confirm the bug in visual studio 2015, but not in visual studio 2017. The Chrome binary I am using was built with visual studio 2015, according to the last line in chrome://version/ Compiling Chrome with a more recent version of visual studio might fix this issue.
,
Feb 14 2017
|
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by dtapu...@chromium.org
, Jan 16 2017