|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68837 integer bcdiv randomly add traling 0
Submitted: 2015-01-15 12:51 UTC Modified: 2017-09-07 09:45 UTC
From: PhoneixSegovia at gmail dot com Assigned: cmb (profile)
Status: Closed Package: BC math related
PHP Version: 5.5.20 OS: Ubuntu
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 - 6 = ?
Subscribe to this entry?

 [2015-01-15 12:51 UTC] PhoneixSegovia at gmail dot com
When you do simple integer division with bcdiv some times the result have trailing 0 and other times is a simply integer (without .000000).

For example with bcdiv('4163592965659328', 32) some times return "130112280176854" but other times return "130112280176854.0000000000".

It appeared to be totally random as you refresh the page.

I have version 5.5.9. I have searched in the bugs but I didn't found any similar bug. Also I know I must use the last version of php to report a bug but I can't do it (company limitation).

Note to use the hard refresh in the test script so the page isn't cached.

Test script:
            echo bcdiv('4163592965659328', 32);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-27 05:13 UTC]
Is there *anywhere* in your code/config/webserver where you set bcmath.scale INI entry?

The extra zeros can result from a non-zero bcmath.scale, though the question then is "Why is scale zero sometimes, then non-zero other times?"  The problem *could* be a threading issue, so I'd ask if you're using PHP in a threaded environment.
 [2017-09-06 16:14 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2017-09-06 16:14 UTC]
Please reply to pollita's questions. Otherwise we have to assume
that there is no bug.
 [2017-09-07 08:43 UTC] PhoneixSegovia at gmail dot com
-Status: Feedback +Status: Closed
 [2017-09-07 08:43 UTC] PhoneixSegovia at gmail dot com
I can't reproduce it now so I suppose it has been fixed.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 01:01:32 2024 UTC