New issue
Advanced search Search tips

Issue 899661 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Nov 1
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

The value is calculated incorrectly

Reported by aleksey....@outlook.com, Oct 29

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36

Steps to reproduce the problem:
1. 2/7 => 0.2857142857142857
2. (2/7).toFixed(2) = > "0.29"
3. parseFloat((2/7).toFixed(2)) => 0.29
4. parseFloat((2/7).toFixed(2))*100 => 28.999999999999996

What is the expected behavior?
parseFloat((2/7).toFixed(2))*100 => 29

What went wrong?
parseFloat((2/7).toFixed(2))*100 => 28.999999999999996

Did this work before? N/A 

Chrome version: 70.0.3538.77  Channel: stable
OS Version: 10.0
Flash Version: 

In IE works correctly
 
The observed behavior is correct as per the JavaScript specification that defines numbers in IEEE 754 format:
http://www.ecma-international.org/ecma-262/8.0/index.html#sec-terms-and-definitions-number-value

It's possible IE applies nonstandard tweaks in this case, but it's not in the specification.

You can find many explanations for the observed behavior, for example:
https://stackoverflow.com/questions/588004/is-floating-point-math-broken
Labels: Needs-Triage-M70
Cc: susan.boorgula@chromium.org
Labels: Triaged-ET Target-72 M-72 FoundIn-71 FoundIn-70 FoundIn-72 OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
aleksey.grigorev@ Thanks for the issue.

Able to reproduce the issue on Windows 10, Mac OS 10.13.6 and Ubuntu 17.10 on the latest Stable 70.0.3538.77 and the latest Canary 72.0.3596.0.
Attached is the screen shot for reference.

This is a Non-Regression issue as this is observed from M-60 chrome builds.
Hence marking this as Untriaged for further updates from Dev.

Thanks..
899661-M60.PNG
44.6 KB View Download
Components: -Blink Blink>JavaScript
Status: WontFix (was: Untriaged)
Agree with the explanation in #1 - this is how floating point math works.

Sign in to add a comment