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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -