Created
February 2, 2013 18:48
-
-
Save itspriddle/4698767 to your computer and use it in GitHub Desktop.
This is why you shouldn't use floating points for money in your app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ > node -e "console.log((0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3))" | |
false | |
~ > php -r "var_dump((0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3));" | |
bool(false) | |
~ > ruby -e "p (0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3)" | |
false | |
~ > python -c "print (0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3)" | |
False | |
~ > perl -e "print ((0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3) ? 'true' : 'false')" | |
false | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found this via: