Round functions in PHP still returns float!

When you round any float number to integer, rounding function (for example floor) still returns float type variable! What?

Well… on second thought, this is reasonable (and explained). PHP does it, because “the value range of float is usually bigger than that of integer“.

So, for example, if you would try to round a number bigger, that integer type can handle (> 2 147 483 647), PHP wouldn’t be able to do anything with the result of such rounding, if it would return it as integer.

Leave a Reply