#28228 [Opn->Csd]: number_format function bug
| From: | iliaa@php.net | Date: | Fri, 30 Apr 2004 13:26:31 +0000 |
| Subject: | #28228 [Opn->Csd]: number_format function bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59065@lists.php.net to get a copy of this message | ||
ID: 28228
Updated by: iliaa@php.net
Reported By: bichinhoverde at spwinternet dot com dot br
-Status: Open
+Status: Closed
Bug Type: Unknown/Other Function
Operating System: windows and linux
PHP Version: 4.3.6
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-04-30 09:19:20] derick@php.net
It's not a feature, it's a bug of course.
------------------------------------------------------------------------
[2004-04-30 03:34:07] bichinhoverde at spwinternet dot com dot br
Just in case someone finds this "feature report", here is a work
around:
number_format(1234.5678*100,0,'','');
It prints "123457" as I wanted.
------------------------------------------------------------------------
[2004-04-30 03:22:50] bichinhoverde at spwinternet dot com dot br
I was expecting the same behavior for the decimal point and the
thousands separator. If you write:
number_format(1234.5678, 2, 'a', 'b');
It outputs:
1b234a57
Is it understandable? Does it matter?
If you specify no thousands separator, it displays the number without
it. But the same is not true for the decimal point.
These two lines have the same result:
number_format(1234.5678, 2, '', '');
number_format(1234.5678, 2, '.', '');
It shouldn't be, IMHO.
Now, why would I use fractional numbers without the decial point?
Because I must print bank codes that have currency values in them. They
use fixed point (2 decimal places) instead of floating point. So, $
1234,55 will be 123455 in the bank code. Got it?
------------------------------------------------------------------------
[2004-04-30 03:04:39] amt@php.net
Oops. Disregard that last comment. What I meant to write
was:
This is a bug, not a feature. Why would you want to
print a number without a decimal point? It wouldn't be
the same number. A number without a thousands separator,
however, is still understandable.
------------------------------------------------------------------------
[2004-04-30 03:02:53] amt@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/28228
--
Edit this bug report at http://bugs.php.net/?id=28228&edit=1