In php, when working with very small numbers, how can i see the exact number, and not "2.1934509277344E-5"?
I am working with microtime() to time some scri开发者_开发知识库pts, 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...)
You can use (s)printf
$myVal = 0.0000002;
echo $myVal; // "2.0E-7"
printf("%0.7f", $myVal); // "0.0000002"
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.
精彩评论