#40802 [NEW]: number_format does not fill rounded number with zeros
| From: | taco at procurios dot nl | Date: | Wed, 14 Mar 2007 10:07:19 +0000 |
| Subject: | #40802 [NEW]: number_format does not fill rounded number with zeros | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-110329@lists.php.net to get a copy of this message | ||
From: taco at procurios dot nl
Operating system: Linux 2.6.17-11-386
PHP version: 5.2.1
PHP Bug Type: *Math Functions
Bug description: number_format does not fill rounded number with zeros
Description:
------------
Since there is no way to tell number_format to use a specified decimal
separator and thousands separator without rounding the number I wanted to
set the amount of decimals bigger than the given amount of decimals to
strip the trailing zeros afterwards.
However, the string number_format returned did not only add zeros to the
given number:
$ php -v
PHP 5.2.1-0.dotdeb.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Feb 9 2007
04:46:32)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
$ php -r "echo number_format(2.333333, 60, ',', '.');"
2,333333000000000101437080957111902534961700439453125000000000
Reproduce code:
---------------
echo number_format(2.333333, 60, ',', '.');
Expected result:
----------------
2,333333000000000000000000000000000000000000000000000000000000
Actual result:
--------------
2,333333000000000101437080957111902534961700439453125000000000
--
Edit bug report at http://bugs.php.net/?id=40802&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40802&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40802&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40802&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40802&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40802&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40802&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40802&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40802&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40802&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40802&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40802&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40802&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40802&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40802&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40802&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40802&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40802&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40802&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40802&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40802&r=mysqlcfg