Why is this microtime showing up weird in PHP

后端 未结 4 1513
栀梦
栀梦 2021-01-17 23:52

Why is this microtime showing up weird in PHP

$start4 = microtime(true);
    // run some php code
$end4 = microtime(true);
print \"Time4: \". ($end4 - $start         


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-01-18 00:24

    It's normal for long numbers (very small or very large) to be converted to powers of 10. The E-5 just means that the number displayed is beeing multiplied by (10/10/10/10/10) which makes it a very small number.

    0.000000000000123 is much harder to read than 1.23E-13 (for example).

    Nevertheless if you do want to view the number in another format:

    $start = microtime(true);
    $end = microtime(true);
    echo "Time: ", number_format($end - $start, 50);
    

    This will add 50 decimal houses to the number on display.

    Hope it helps!

提交回复
热议问题