ID:               47633
 User updated by:  k1ngrs at ntlworld dot com
 Reported By:      k1ngrs at ntlworld dot com
 Status:           Open
 Bug Type:         BC math related
 Operating System: Windows XP Pro SP2
 PHP Version:      5.2.9
 New Comment:

I think I have uncovered the reason for the issue and that is that the
function expects a string and I have passed a floating point number
which OK to a point. Once you go smaller than 0.0001 you transfer a
scientific notation to the function that does not compute.
So the answer is to convert it first using number_format.
Regards
Rob


Previous Comments:
------------------------------------------------------------------------

[2009-03-12 11:59:00] k1ngrs at ntlworld dot com

Description:
------------
The bcmath commands do not seem to work for numbers smaller than
0.0001
for exmaple if you add 0.00001 and 0.00001 the result is zero.
Even setting the bcscale beforehand does not fix the issue.



Reproduce code:
---------------
<?php
$a =bcadd(0.00011,0.00011,6);
$b =bcadd(0.00001,0.00001,6);
$c =bcsub((double)0.00001,(double)0.000005,6);
echo "1. 0.00011 + 0.00011 = $a OK\r\n";
echo "2. 0.00001 + 0.00001 = $b Wrong\r\n";
echo "3. 0.00001 - 0.000005 = $c Wrong\r\n";
?>

Expected result:
----------------
1. 0.00011 + 0.00011 = 0.000220 
2. 0.00001 + 0.00001 = 0.00002 
3. 0.00001 - 0.000005 = 0.000005

Actual result:
--------------
1. 0.00011 + 0.00011 = 0.000220 OK
2. 0.00001 + 0.00001 = 0.000000 Wrong
3. 0.00001 - 0.000005 = 0.000000 Wrong


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47633&edit=1

Reply via email to