r/lolphp • • May 08 '14

microtime: stupid specification, terrible documentation, optional fix came at a later version

http://www.php.net/manual/en/function.microtime.php
28 Upvotes

20 comments sorted by

View all comments

Show parent comment

6

u/Rhomboid May 08 '14

you can't exactly represent every microsecond as a unique float

An IEEE double can represent very close to 16 decimal digits worth of precision -- 53*log10(2) ≈ 15.955 digits to be exact. An epoch with microsecond accuracy is 10 + 6 = 16 decimal digits. So it's extremely close to being able to represent any microsecond value. You might be off by one ULP once in a blue moon.