From: benjcarson at digitaljunkies dot ca Operating system: Linux PHP version: 5CVS-2004-08-11 (dev) PHP Bug Type: Strings related Bug description: money_format treats 0.00*-1 strangely
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 bug report at http://bugs.php.net/?id=29620&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29620&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29620&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29620&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29620&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29620&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29620&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29620&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29620&r=support Expected behavior: http://bugs.php.net/fix.php?id=29620&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29620&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29620&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29620&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29620&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29620&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29620&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29620&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29620&r=float