php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: PhoneixSegovia at gmail dot com
New email:
PHP Version: OS:

 

 [2015-01-15 12:51 UTC] PhoneixSegovia at gmail dot com
Description:
------------
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:
---------------
<!DOCTYPE HTML>
<html>
    <body>
        <?php
            echo bcdiv('4163592965659328', 32);
        ?>
    </body>
</html>

Expected result:
----------------
130112280176854

Actual result:
--------------
130112280176854.0000000000

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-27 05:13 UTC] pollita@php.net
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] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2017-09-06 16:14 UTC] cmb@php.net
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: Wed Apr 24 01:01:31 2024 UTC