Skip to content

Instantly share code, notes, and snippets.

@berkes
Created June 23, 2012 22:03
Show Gist options
  • Select an option

  • Save berkes/2980236 to your computer and use it in GitHub Desktop.

Select an option

Save berkes/2980236 to your computer and use it in GitHub Desktop.
gotcha with PHP typecasting
<?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.
@berkes
Copy link
Copy Markdown
Author

berkes commented Jun 24, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment