jug Posted March 31, 2010 Share Posted March 31, 2010 Hi, Looking through previous posts there is one thread that I found that covers the issue but the solution did not work for me. http://www.phpfreaks.com/forums/index.php/topic,214582.msg980170.html#msg980170 What I am trying to do is use microtime to see how long a script takes to execute. Im expecting a figure that is below one, for example 0.034532. But what I am getting is a figure similar to 2.9999999999974E-5. What does this mean? And how can I solve it? The code I am using is below and is very simple and almost identical to one example found in the documentation on php.net. $time_start = microtime(true); //script here $time_end = microtime(true); $time_taken = $time_end - $time_start; echo ' Time taken: ' . $time_taken; Thanks in advance jug Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 31, 2010 Share Posted March 31, 2010 2.9999999999974E-5s = 0.000029...s = 0.00003s Quote Link to comment Share on other sites More sharing options...
jug Posted April 1, 2010 Author Share Posted April 1, 2010 Thanks for that. I was sure it meant something. Anyone know (out of curiousity) why PHP doesnt just say 0.000029...s rather than 2.9999999999974E-5s? jug Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 1, 2010 Share Posted April 1, 2010 Because it's been designed to switch to scientific notation when a floating point number is below or above certain range. To keep decimal notation use sprintf Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.