casting - PHP cast to integer returns wrong value -


have @ friend , tell me i'm not crazy...

echo (int) (9.45 * 100); // gives 944 echo (int) 945; // gives 945 

i don't understand why first instruction return 944!???? known php issue? appreciated always!

according php documentation (http://php.net/manual/en/language.types.integer.php)

when converting float integer, number rounded towards zero.  

that's why getting 944.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -