php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79001 subtraction int from microtime(true) give a wrong result
Submitted: 2019-12-19 14:00 UTC Modified: 2019-12-19 15:14 UTC
From: dromidror at yahoo dot com Assigned: cmb (profile)
Status: Not a bug Package: Math related
PHP Version: 7.4.1 OS: Ubuntu 16.04.6 LTS (GNU/Linux 4.
Private report: No CVE-ID: None
 [2019-12-19 14:00 UTC] dromidror at yahoo dot com
Description:
------------
$now_time - is the result of function microtime(true)*10000. The value is a allegedly whole number with 14 digits. ( e.g. 15767617663680).

$start - is constant with value in range of $now_time value(14 digits)
$run - the result of subtracting start from now_time

Test script:
---------------
<?php
$now_time = microtime(true)*10000;
$start = 15767602956637;
$run = $now_time -$start ;
echo ($now_time - $start), " = ", $now_time, " - ", $start;


Expected result:
----------------
14707043 = 15767617663680-15767602956637


Actual result:
--------------
14707043.460938 = 15767617663680-15767602956637

Notice that PHP returns number with friction (14707043.460938) as result of subtracting two allegedly whole numbers(15767617663680 and 15767602956637).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-19 15:14 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2019-12-19 15:14 UTC] cmb@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

| If get_as_float is set to TRUE, then microtime() returns a float,
| which represents the current time in seconds since the Unix epoch
| accurate to the nearest microsecond.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 05 06:01:28 2024 UTC