Skip to content
Advertisement

Tag: type-conversion

PHP unexpected result of float to int type cast

I’trying to convert a float to an int value in php: I can use ceil to make it work but can somebody explain this to me? Answer This is because numbers that have a finite representation in base 10 may or may not have an exact representation in the floating point representation PHP uses. See >php -r “echo var_dump(sprintf(‘%.40F’, 39.3

Advertisement