|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62792 number_format with largue numbers is broken
Submitted: 2012-08-10 13:39 UTC Modified: 2012-08-13 11:15 UTC
From: brodanoel at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.3.15 OS: Red Hat
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
26 - 23 = ?
Subscribe to this entry?

 [2012-08-10 13:39 UTC] brodanoel at gmail dot com
Using the number_format function with largue numbers, the value returned is the real + 1

Test script:
number_format(9999999999999999999, 0, '', '.')

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-11 04:40 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.

 [2012-08-11 04:40 UTC]
-Status: Open +Status: Not a bug
 [2012-08-13 10:29 UTC] brodanoel at gmail dot com
But... Here not have float numbers. Is a Integer.
And is not necesary a Mathematical operation in this function (number_format)
 [2012-08-13 11:15 UTC]
9999999999999999999 is beyond the maximum value an integer variable can hold in 
PHP, and is automatically converted to a floating point value.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 22 16:01:24 2020 UTC