#46781 [Opn->Bgs]: BC math handles minus zero incorrectly

From: Date: Wed, 21 Jan 2009 20:01:12 +0000
Subject: #46781 [Opn->Bgs]: BC math handles minus zero incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133129@lists.php.net to get a copy of this message
ID: 46781 Updated by: jani@php.net Reported By: preechaw at gmail dot com -Status: Open +Status: Bogus Bug Type: BC math related Operating System: Windows XP PHP Version: 5.2.7 New Comment: I get the expected result with current release. (5.2.8) Previous Comments: ------------------------------------------------------------------------ [2008-12-06 12:39:40] preechaw at gmail dot com 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 this bug report at http://bugs.php.net/?id=46781&edit=1

« previous php.bugs (#133129) next »