|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66364 BCMath bcmul ignores scale parameter
Submitted: 2013-12-28 03:39 UTC Modified: 2017-09-18 13:23 UTC
Avg. Score:4.0 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:0 (0.0%)
From: self at jacobbudin dot com Assigned: cmb (profile)
Status: Closed Package: BC math related
PHP Version: 5.5.7 OS: Fedora 20
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: self at jacobbudin dot com
New email:
PHP Version: OS:


 [2013-12-28 03:39 UTC] self at jacobbudin dot com
BCMath's bcmul function ignores the scale parameter. When the result's scale has fewer the digits than the requested scale, the trailing zeros are not appended to the returned string as is the case with bcadd, bcsub, and bcdiv.

Test script:
<?php echo bcmul("0.3", "0.2", 4);

Expected result:

Actual result:


bcmul-scale (last revision 2013-12-28 03:40 UTC by self at jacobbudin dot com)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-27 05:16 UTC]
-Status: Open +Status: Analyzed
 [2016-07-27 05:16 UTC]
bcmul() *sort-of* ignores scale.  What it does is treat the scale param as a "maximum scale".  In the case of your example, the answer only has two significant decimal places, so the scale parameter of 4 is truncated to 2.

That said, this seems to disagree with most other bcmath functions, so I'm less likely to call it a documentation problem and consider it a real bug.
 [2016-12-06 17:29 UTC] powtac at gmx dot de
The problem also exists on PHP 5.6.25 Ubuntu.
 [2017-09-18 13:21 UTC]
Automatic comment on behalf of
Log: Fixed bug #66364 (BCMath bcmul ignores scale parameter)
 [2017-09-18 13:21 UTC]
-Status: Analyzed +Status: Closed
 [2017-09-18 13:23 UTC]
-Assigned To: +Assigned To: cmb
 [2017-09-18 13:23 UTC]
This issue will be fixed as of PHP 7.3.0 only, to mitigate the BC
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 21 21:01:31 2024 UTC