php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75098 Unexpected output
Submitted: 2017-08-20 07:31 UTC Modified: 2017-08-22 05:52 UTC
From: coolbalyan at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.1.8 OS: window,ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: coolbalyan at gmail dot com
New email:
PHP Version: OS:

 

 [2017-08-20 07:31 UTC] coolbalyan at gmail dot com
Description:
------------
When script subtract value from two "microtime", it produce value in unexpected way. script take almost a fraction on second but substraction of value from taken from "microtime" make it incremented. it looks like it taking near around 9-10 seconds.

Test script:
---------------
$time_start=microtime(TRUE);


/****Performance Check****/
$time_end=microtime(TRUE);
var_dump(PHP_VERSION, $time_end-$time_start);



Expected result:
----------------
0

Actual result:
--------------
9.5367431640625E-7

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-20 07:49 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-08-20 07:49 UTC] requinix@php.net
Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://www.floating-point-gui.de/

Thank you for your interest in PHP.

> it looks like it taking near around 9-10 seconds.
https://en.wikipedia.org/wiki/Scientific_notation#E-notation
 [2017-08-22 04:58 UTC] coolbalyan at gmail dot com
-Operating System: window +Operating System: window,ubuntu
 [2017-08-22 04:58 UTC] coolbalyan at gmail dot com
If you run the test script, it actually produces that result without taking 9 seconds. That's odd, the script holding only 

$time_start=microtime(TRUE);


/****Performance Check****/
$time_end=microtime(TRUE);
var_dump(PHP_VERSION, $time_end-$time_start);

I actually rerun it in PHP 5.6.20 and 7.1.6 it returns float(0) but in 7.1.8 and 7.0.22 it returns higher values.
 [2017-08-22 05:14 UTC] spam2 at rhsoft dot net
what about reading the links you got already provided - it does NOT take 9 seconds notice the E-7 which means "move the comma 7 positions left"
 [2017-08-22 05:52 UTC] coolbalyan at gmail dot com
Thanks, not a bug
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 15:01:35 2025 UTC