Created
June 23, 2012 22:03
-
-
Save berkes/2980236 to your computer and use it in GitHub Desktop.
gotcha with PHP typecasting
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
<?php | |
$amount = 17.50; | |
print (int) $amount * 100; # => 1700 # My implementation. I was wrong. | |
print (int) ($amount * 100); # => 1750 # After bugfix. PHP first casts, then multiplies. |
Author
berkes
commented
Jun 24, 2012
via email
Heh. Thanks. I had to "anonimize" the price a little. But forgot half of hem :)
Changed it :P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment