|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
30 - 27 = ?
Subscribe to this entry?

 [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-2023 The PHP Group
All rights reserved.
Last updated: Tue May 30 00:03:41 2023 UTC