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
Post a Comment