Be careful with JS numbers!

Posted: January 15, 2013 Comments

View http://blog.greweb.fr/2013/01/be-careful-with-js-numbers/

There’s no denying that JavaScript has it’s quirks. Over time you get bitten by one, then another, then you hate writing JavaScript, then you really like writing it again, and you begin to learn more about the beast and come to embrace it. One of the hardest lessons I learned some time ago was just how bad JavaScript is at math. If you’ve taken a look at some other code, you’ve likely noticed that if done properly, money calculations are composed of integers. That’s because JavaScript can’t perform arithmetic on floats with trustable accuracy. This article points out a few other issues you should keep in mind as you script.

Get my newsletter

Receive periodic updates right in the mail!
  • This field is for validation purposes and should be left unchanged.

Leave a Reply

Your email address will not be published.