|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67163 Return incorrect values.
Submitted: 2014-04-30 21:15 UTC Modified: 2014-04-30 22:44 UTC
From: useful-soft at yandex dot ru Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.4.27 OS: Debian 7 64x
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: useful-soft at yandex dot ru
New email:
PHP Version: OS:


 [2014-04-30 21:15 UTC] useful-soft at yandex dot ru
Tested in PHP 5.4.27 and PHP 5.4.15

Return incorrect values.

Test script:
echo number_format( 1.7976931348623157e+308, 2 );
// Result: 179,769,313,486,231,570,814,527,423,731,704,356,798,070,567,525,844,996,598,917,476,803,157,260,780,028,538,760,589,558,632,766,878,171,540,458,953,514,382,464,234,321,326,889,464,182,768,467,546,703,537,516,986,049,910,576,551,282,076,245,490,090,389,328,944,075,868,508,455,133,942,304,583,236,903,222,948,165,808,559,332,123,348,274,797,826,204,144,723,168,738,177,180,919,299,881,250,404,026,184,124,858,368.00

echo round( 1.7976931348623157e+308, 2 );
// Result: 1.7976931348623157e+308


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-30 22:44 UTC]
-Status: Open +Status: Not a bug
 [2014-04-30 22:44 UTC]
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:

Thank you for your interest in PHP.

Besides, 1.7976931348623157e+308 rounded to two decimal places is still 1.7976931348623157e+308. If you want string output then use a different function - such as number_format() with an empty string as the thousands separator.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 11:01:27 2023 UTC