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:
,
Jun 2 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by woxxom@gmail.com
, Jun 2 2017