tags:

views:

130

answers:

3
<?php

$start = microtime(true);
$end = microtime(true);

echo $end - $start;

?>

Why does this code produce results like:

1.1920928955078E-5,
5.9604644775391E-6,
6.9141387939453E-6

What does the E-5, E-6 mean ?

And why the heck is the difference so big ? From 1,1 sec to 6,9 sec ?

Thanks!

+1  A: 

E is a scientific notation. E-x means that there are a certain amount of zeroes infront of the result you got.

Check out this table to see what each result means.

In your example, you have 1,0E-6 which is 0,000001 which is Micro.

Ólafur Waage
+1  A: 

1.1920928955078E-5 means 1.1920928955078 * 10^-5 == 0.000011920...

So your difference is:

0,000011920 0,000005960 0,000006914

So its within a factor of ~2 not ~6

veggerby
+5  A: 

E is scientific or exponential notation where each number is represented as a x 10b, so aEb means to multiply by a by 10b. So when b = -5, then you multiply by 10-5 (same as dividing by 105) or move the decimal place 5 places to the left. When b is positive, then move the decimal place that many places to the right. Note that in scientific notation there is always a single digit to the left of the decimal.

So

1.1920928955078E-5 = 0.000011920928955078

5.9604644775391E-6 = 0.0000059604644775391

6.9141387939453E-6 = 0.0000069141387939453

The differences are actually very small - a few microseconds.

tvanfosson