Bug #13551 Updated: BC functions apply decimal places argument also on arguments
| From: | manuel@php.net | Date: | Fri, 05 Oct 2001 13:02:56 +0000 |
| Subject: | Bug #13551 Updated: BC functions apply decimal places argument also on arguments | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-67342@lists.php.net to get a copy of this message | ||
ID: 13551
Updated by: manuel
Reported By: mlemos@acm.org
Old Status: Analyzed
Status: Open
Old Bug Type: Documentation problem
Bug Type: BC math related
Operating System: Linux 2.2.18
PHP Version: 4.0.6
New Comment:
That is incorrect. BC is for arbitrary percision arithmetic. Arguments should be strings not
integers. Just change the precision argument in the example from 0 to 2 and you will see that it
will consider the decimal places of the multiplication arguments.
The problem is that the way PHP BC module is working is that it applies the decimal places to
arguments when it should only apply to the result.
bcmul('8.78','100',2) should be '878.00'
and
bcmul('8.78','100',0) should be '878' and not '800',
otherwise BC PHP module is useless because you can't perform a calculation and control the
decimal places of the result without affecting the operands.
It should work like sprintf("%.2f",$operand_1*$operand_2) where 2 is the number of decimal
places of the output and and not of the operand values because these may have much more decimal
places than the result.
Previous Comments:
------------------------------------------------------------------------
[2001-10-05 02:21:10] derick@php.net
It's not a bug, but a feature (tm). BC only works with integer values, and all arguments must
be integer values.
However, the documentation is not quite clear here.
Derick
------------------------------------------------------------------------
[2001-10-04 19:49:04] mfischer@php.net
Confirmed with latest CVS. Either the documentation is wrong or the implementation. Both won't
need rocket sience to fix ...
Btw, this seems to be true for all bc*() functions.
Probably the documentation isn't clear enough about the current behaviour. Andi?
- Markus
------------------------------------------------------------------------
[2001-10-04 19:18:17] mlemos@acm.org
BC functions apply decimal places also on arguments but it should only apply them on the result.
For example bcmul('8.78','100',0) should return 878 and not 800 as it does now.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=13551&edit=1