When i make the following multiplication in PHP:
$ret = 1.0 * 0.000000001;
i get the result: 1.0E-9
I want to convert this result into the normal decimal notation, how can i do this?
sprintf('%f',$ret)
doesn't work, it returns 0.000000
. Overflow?
sprintf
works, however you miss some point here.0.000000
is not overflow. It's just thatsprintf
for the%f
modifier uses 6 digits per default. Also please take care that%f
is locale aware,%F
is probably better suited.You might want to use more digits, e.g. let's say 4 000 000 (four million):
As this example shows, there is not only a common value (6 digits) but also a maximum (probably depended on the computer system PHP executes on), here truncated to 53 digits in my case as the warning shows.
Because of your question I'd say you want to display:
Which are nine digits, so you need to write it that way:
However, you might want to do this:
which will remove zeroes from the right afterwards:
Hope this is helpful.