From: preechaw at gmail dot com
Operating system: Windows XP
PHP version: 5.2.7
PHP Bug Type: BC math related
Bug description: BC math handles minus zero incorrectly
Description:
------------
bcadd("-0.0", "-0.0", 1); // returns -0.0
bccomp("-0.0", "0", 1); // returns -1
I believe that the first expression should return '0.0',
and the second one should return 0.
The second expression implies that "-0.0" is mathematically less than "0",
which is incorrect.
--
I also submitted another bug related to minus zero.
echo -0.1 * 0; // returns -0
--
Reproduce code:
---------------
<?php
echo bcadd("-0.0", "-0.0", 1) . "<br>\n"; // returns -0.0
echo bccomp("-0.0", "0", 1) . "<br>\n"; // returns -1
?>
Expected result:
----------------
-0.0
-1
Actual result:
--------------
0.0
0
--
Edit bug report at http://bugs.php.net/?id=46781&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46781&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46781&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46781&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46781&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46781&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46781&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46781&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46781&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46781&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46781&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46781&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46781&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46781&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46781&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46781&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46781&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46781&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46781&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46781&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46781&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46781&r=mysqlcfg