|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-12-06 12:39 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 19:00:02 2025 UTC |
jani@php.net, "expected result" that you got is obviously incorrect. I am using PHP 5.3.3 and this bug still exists. Please change the bug status. Thank you. Reproduce code: --------------- <?php bcscale(2); print bcadd('-0.0', '-0.0') . '<br>'; // prints: -0.00, should be: 0.00 print bccomp('-0.0', '0') . '<br>'; // prints: -1, should be: 0 ?>