note 9309 deleted from function.bcmul by didou
| From: | didou@php.net | Date: | Tue, 16 Dec 2003 12:43:12 +0000 |
| Subject: | note 9309 deleted from function.bcmul by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62045@lists.php.net to get a copy of this message | ||
Note Submitter: chris.key@wcom.com
----
[Editor's note: It is not that the parameter is not optional, but that when using the bc*
functions, you should defined the scale beforehand using bcscale(), e.g. in the example below you
should use "bcscale(3);" before you use bcmul/bcdiv/etc.]
bcmul optional scale parameter is not optional. Given the following code:
echo "A: ".(2900000 / 500)."\n";
echo "C: ".bcdiv( (290000 / 500), 290000, 5). "\n";
echo "K: ".bcmul( bcdiv( (290000 / 500), 290000, 5), 290000,3)."\n";
echo "ACK: ". bcmul( bcdiv( (290000 / 500), 290000, 5), 2900000);
Should yield:
A: 646.654
C: 0.00200
K: 646.654
ACK: 646
But instead gives:
A: 646.654
C: 0.00200
K: 646.654
ACK: 0
Even if there is an integer portion of the result, it will return 0 unless the scale parameter is
set to the number of non-zero digits after the decimal.