Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
JavaScript bug: 2*2=4.000000003 ??
Hi, I am note experienced in JS, and I think many of you are acquainted with the problem. When I perform simplest arythmetic operations, JS returns these little bugs like 3*4=11.99999999999 etc. For real life example, choose detailed mode, 6 pages, 6 hours delivery, and don't check the specific checkbox at this paper price estimator test page (JS gurus please don't laugh at me). And then check the checkbox and submit again. This is completely irrational and wrong; I know it's a JS bug. What do I do with it?
Thanks
Thanks
0
This discussion has been closed.
Comments
Math.round(25.2) //returns 25
Math.round(-2.58) //returns -3
Math.round(11.99999999999) //returns 12
Posted: Wednesday, 11 July 2007 at 10:43AM
function roundNumber(num, dec) { var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); return result; }
Then use it like:
var roundedNumber = roundNumber(annualPremium,2)