php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47107 numbers with more than 15 digits are not behaved normally
Submitted: 2009-01-14 19:57 UTC Modified: 2009-05-01 07:53 UTC
From: mucahitkahveci at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.2 OS: Windows xp sp2
Private report: No CVE-ID: None
 [2009-01-14 19:57 UTC] mucahitkahveci at gmail dot com
Description:
------------
printf('%f', 55555555555555555555);

prints 55555555555555557376.000000

This number (555...) has 20 digits this happen in any number with more than 15 digits

Reproduce code:
---------------
printf('%f', 55555555555555555555);

Expected result:
----------------
55555555555555555555.000000

Actual result:
--------------
55555555555555557376.000000

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-15 12:48 UTC] jani@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://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.

And 32bit issue..etc. etc. No bug.
 [2009-05-01 07:53 UTC] mucahitkahveci at gmail dot com
I understand that, but isn't it a big problem? Since php supports integers for "maximum value of about two billion" (php manual) in which it than changes to floating point numbers for numbers bigger than this.
So for any value its bigger than 15 digit its a very very big problem while querying in a database. For example mysql has bigint type which supports a maximum of 20 digits. But because of this behaviour of php we have to use only upto 15 digits!! And if someone skips this detail it would cause problems that is impossible to solve

Thanks
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 13:01:31 2025 UTC