StackOverflowNewbie StackOverflowNewbie - 6 months ago 31
PHP Question

PHP float with 2 decimal places: .00

When I do this typecasting:

(float) '0.00';

I get
. How do I get
and still have the data type as a float?


You don't have 0 or 0.00 : those are different representations of the internal (IEEE754) binary format.

If you want to express your float as "0.00", you need to format it in a string, using number_format :

$numberAsString = number_format($numberAsFloat, 2);