Bug #68473 [NEW]: number_format results on high numbers?
| From: | php at kingsquare dot nl | Date: | Fri, 21 Nov 2014 16:46:11 +0000 |
| Subject: | Bug #68473 [NEW]: number_format results on high numbers? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-188732@lists.php.net to get a copy of this message | ||
From: php at kingsquare dot nl
Operating system: n/a
PHP version: 5.6.3
Package: *General Issues
Bug Type: Bug
Bug description:number_format results on high numbers?
Description:
------------
We're seeing issues with number_format and strange behaviour. It seems
to be rounding off / exceeding some kind of _undocumented_ limit ?
(related bug: 62792, but the response there is irrelevant since the
PHP_INT_MAX isnt even reached in some cases and still the error
persists? And before you go 'floating points and limited percision: this
is an int, not a float... :) )
Test script:
---------------
<?php
echo PHP_INT_MAX.PHP_EOL;
echo number_format(PHP_INT_MAX, 0, '', '').PHP_EOL; // ?
echo '4'.PHP_EOL;
echo number_format(4, 0, '', '').PHP_EOL; // as expected
echo '23372036854775807'.PHP_EOL;
echo number_format('23372036854775807', 0, '', '').PHP_EOL; // still
errors
echo '3372036854775807'.PHP_EOL;
echo number_format('3372036854775807', 0, '', '').PHP_EOL; // yeah!
the
same results :)
Expected result:
----------------
9223372036854775807
9223372036854775807
4
4
23372036854775807
23372036854775807
3372036854775807
3372036854775807
Actual result:
--------------
9223372036854775807
9223372036854775808
4
4
23372036854775807
23372036854775808
3372036854775807
3372036854775807
--
Edit bug report at https://bugs.php.net/bug.php?id=68473&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68473&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68473&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68473&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68473&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68473&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68473&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68473&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68473&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68473&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68473&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68473&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68473&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68473&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68473&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68473&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68473&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68473&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68473&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68473&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68473&r=mysqlcfg