#29620 [Opn->Bgs]: money_format treats 0.00*-1 strangely
ID: 29620
Updated by: iliaa@php.net
Reported By: benjcarson at digitaljunkies dot ca
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Linux
PHP Version: 5CVS-2004-08-11 (dev)
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
the money_format() function returns the exact same value as
that of strfmon() without any modifications. Any unexpected
output is likely to be a fault in glibc.
Previous Comments:
------------------------------------------------------------------------
[2004-08-11 20:56:49] benjcarson at digitaljunkies dot ca
Description:
------------
When using the format '%(n' (i.e. represent negative numbers in
parenthesis), money_format still prints out a negative sign when its
second parameter is 0.00*-1. It works fine for the following values,
however:
-0.00
-0
0*-1
-1*0
-1*0.00
-1.00*0
(Note: echo(0.00*-1) prints out -0.)
Interestingly, using gcc-3.3.4 and glibc-2.3.2, the following fails in
a similar fashion:
strfmon(buf, sizeof(buf), "%(n", atof("-0.00"));
/* buf = "-0.00" */
double val = 0.00 * -1;
strfmon(buf, sizeof(buf), "%(n", val);
/* buf = "-0.00" */
double val = -1*0.00;
strfmon(buf, sizeof(buf), "%(n", val);
/* buf = "-0.00" */
It appears it might have something to do with strfmon()'s handling of
'negative zero', except money_format() works correctly for values where
strfmon() fails (e.g. -1*0.00).
Reproduce code:
---------------
echo money_format("%(n", 0.00*-1) . "\n";
Expected result:
----------------
0.00
or even
(0.00)
Actual result:
--------------
-0.00
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29620&edit=1
Thread (2 messages)