toFixed() does not properly rounds a number
Reported by
kochelor...@gmail.com,
Oct 26 2017
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Steps to reproduce the problem: 1. Run the following code in dev console: `4.755.toFixed(2)` What is the expected behavior? I expect the result to be: "4.76" What went wrong? The actual result is "4.75" Did this work before? N/A Chrome version: 61.0.3163.100 Channel: n/a OS Version: OS X 10.12.6 Flash Version: Same issue with `47.55.toFixed(1)` and `0.4755.toFixed(3)`
,
Oct 26 2017
,
Oct 26 2017
,
Oct 27 2017
Tested on latest Chrome Stable #62.0.3202.75, Canary #64.0.3251.0 and Chrome #50.0.2624.0 on Windows 10, Mac 10.12.6 and Ubuntu 14.04 and able to reproduce the issue. This is a non-regression issue and able to reproduce from M-50 #50.0.2624.0. Marking it as untriaged so that issue gets addressed. Attached the screenshot for reference. Thanks.
,
Oct 30 2017
This is probably due to imprecision of the floating point representation. Firefox behaves the same. |
||||
►
Sign in to add a comment |
||||
Comment 1 by kochelor...@gmail.com
, Oct 26 2017