New issue
Advanced search Search tips

Issue 728744 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jun 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Math.round() Does not Perfectly Round

Reported by mattnut...@gmail.com, Jun 1 2017

Issue description

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

Steps to reproduce the problem:
1. Round a variable to 4 decimals.
2. Multiply the variable by 100.
3. Output the results.

Example code:
<script>
var myVar = 0.07094330288549908;
myVar = Math.round(myVar * 10000) / 10000;
myVar = myVar * 100;
alert("This is not a rounded value: " + myVar);
</script>

What is the expected behavior?
The expected value of the variable myVar would be: 7.09

What went wrong?
The actual value of the variable myVar comes out as: 7.090000000000001

Did this work before? No 

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

Comment 1 by woxxom@gmail.com, Jun 2 2017

Numbers in JavaScript are implemented using IEEE 754 double-precision specification [1] which means only 15 digits can be reliably represented.

  [1]: https://en.wikipedia.org/wiki/IEEE_floating_point#Basic_and_interchange_formats
Status: WontFix (was: Unconfirmed)

Sign in to add a comment