php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76418 The scale is not set, but there are two decimal places.
Submitted: 2018-06-06 10:28 UTC Modified: 2018-06-08 02:55 UTC
From: zh9025 at qq dot com Assigned: cmb (profile)
Status: Not a bug Package: BC math related
PHP Version: 7.1.18 OS: CentOS Linux release 7.4.1708 (C
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: zh9025 at qq dot com
New email:
PHP Version: OS:

 

 [2018-06-06 10:28 UTC] zh9025 at qq dot com
Description:
------------
---
From manual page: http://www.php.net/function.bcmul
---


Test script:
---------------
<?php
// Test Url http://tb.besoft.top/bcmul.php 需要多次刷新 20%左右概率出现1
var_dump(bcmul(0.01, 100));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-06 10:34 UTC] zh9025 at qq dot com
1.正常情况下 应该是1,而不是1.00
2.刷新多次结果还可能变成1
 [2018-06-06 10:36 UTC] spam2 at rhsoft dot net
please, this is an english bugtracker - i don't write german here too
 [2018-06-06 10:41 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2018-06-06 10:41 UTC] requinix@php.net
http://php.net/manual/zh/function.bcmul.php
> left_operand
> 字符串类型的左操作数.
> right_operand
> 字符串类型的右操作数.

Please try
  var_dump(bcmul("0.01", "100"));
 [2018-06-06 10:48 UTC] zh9025 at qq dot com
Test script:
---------------
<?php echo bcmul("0.01", 100);

<?php echo bcmul(0.01, 100);

Expected result:
----------------
1

Actual result:
--------------
1.00

Test link:
--------------
Refresh multiple times, and the result can also be 1
 [2018-06-06 13:26 UTC] zh9025 at qq dot com
-Summary: 高精度乘法运算一会有小数点 一会没有 +Summary: The scale is not set, but there are two decimal places. -Status: Feedback +Status: Open
 [2018-06-06 13:26 UTC] zh9025 at qq dot com
The scale is not set, but there are two decimal places.

Test script:
---------------
<?php echo bcmul("0.01", 100);

<?php echo bcmul(0.01, 100);

Expected result:
----------------
1

Actual result:
--------------
1.00

Test link:
--------------
http://tb.besoft.top/bcmul.php

Refresh multiple times, and the result can also be 1
 [2018-06-07 16:52 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-06-07 16:52 UTC] cmb@php.net
Please run without SourceGuardian, just to make sure it is not
related to this extension.
 [2018-06-07 16:52 UTC] cmb@php.net
Please run without SourceGuardian, just to make sure it is not
related to this extension.
 [2018-06-08 02:33 UTC] zh9025 at qq dot com
-Status: Feedback +Status: Assigned
 [2018-06-08 02:33 UTC] zh9025 at qq dot com
Thank you for your help, and it's really the reason for the SourceGuardian extension.
 [2018-06-08 02:34 UTC] zh9025 at qq dot com
-Status: Assigned +Status: Closed
 [2018-06-08 02:34 UTC] zh9025 at qq dot com
Thank you for your help, and it's really the reason for the SourceGuardian extension.
 [2018-06-08 02:55 UTC] requinix@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 19:01:33 2024 UTC