tags:

views:

59

answers:

2

Hi,

I am working with microtime() to time some scripts, but all the scripts have really quick times, eg 2.1934509277344E-5

how can i get php to display that correctly without e-5?

(which i assume is 0.000021934509277344? long time since i did maths...)

+4  A: 

You can use (s)printf

$myVal = 0.0000002;
echo $myVal;   // "2.0E-7"
printf("%0.7f", $myVal);  // "0.0000002"
nickf
For further clarification, you can mess around with the number of decimal places it shows by changing the first parameter of the printf function. "%0.7f" = floating point # with 7 digits after the decimal.
SauceMaster
A: 

Try this: trim(sprintf('%40.20f', 2.1934509277344E-5)). %40.20f tells sprintf to display 40 digit with 20 digit of decimal. You can adjust this as you wish. The number will be space-led to fill 40 digits so I trim it.

Hope this helps.

NawaMan
you could just use `%0.20f`, which won't pad to the left at all.
nickf