show double when cycle a for with decimal distinct .5
Reported by
angel.ol...@gmail.com,
Mar 9 2018
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
Steps to reproduce the problem:
this.stepsSize = []
for (i = 0.5; i <= 2; i = i + 0.2) {
console.log(i);
var size_name = i + " em"
console.log(size_name);
this.stepsSize.push({ name: size_name, value: i });
}
What is the expected behavior?
0.5
0.5 em
0.7
0.7 em
0.8999999999999999
0.8999999999999999 em
1.0999999999999999
1.0999999999999999 em
1.2999999999999998
1.2999999999999998 em
1.4999999999999998
1.4999999999999998 em
1.6999999999999997
1.6999999999999997 em
1.8999999999999997
1.8999999999999997 em
What went wrong?
0.5
0.5 em
0.7
0.7 em
0.9
0.9 em
1.11
1.11 em
1.13
1.13 em
1.15
1.15 em
1.17
1.17 em
1.19
1.19 em
Did this work before? N/A
Chrome version: 64.0.3282.186 Channel: stable
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
,
Mar 10 2018
,
Mar 10 2018
I guess this is working as expected or intended as JavaScript number (which is a "double" floating point) cannot represent some numbers exactly as in decimal, but I'll defer this to experts in v8 team.
,
Mar 11 2018
,
Mar 12 2018
angel.oliver.cv@ Thanks for the issue. Able to reproduce the issue on Windows 10, Mac OS 10.12.6 and Ubuntu 14.04 on the latest Canary 67.0.3368.0 and Stable 65.0.3325.146 by following the steps given above. From comment #1, we can understand that the output given under the Expected behavior is the wrong behavior and output given under wrong behavior is the expected behavior. On executing the give code in Devtools -> Console, can see the output as the wrong behavior. Attached is the screen shot for reference. This is a Non-Regression issue as this behavior is observed from M60 Chrome builds. Hence marking this as Untriaged for further updates from Dev. Thanks..
,
Mar 21 2018
This is AFAIK working is intended. See #3. The real expected values are wrong btw. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by angel.ol...@gmail.com
, Mar 9 2018