php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52748 bcpow() - scale parameter doesn't influensce the result string
Submitted: 2010-08-30 22:52 UTC Modified: 2010-09-09 07:45 UTC
From: k.schroeder@php.net Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: trunk-SVN-2010-08-30 (SVN) OS: Windows XP
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: k.schroeder@php.net
New email:
PHP Version: OS:

 

 [2010-08-30 22:52 UTC] k.schroeder@php.net
Description:
------------
Executing bcpow('-2', '5') and bcpow('-2', '5', 2) results in same string ("-32").

Test script:
---------------
--TEST--
bcpow() - scale parameter doesn't influensce the result string
--SKIPIF--
<?php if(! extension_loaded('bcmath')) print 'extension bcmath not loaded'; ?>
--INI--
bcmath.scale=0
--FILE--
<?php
var_dump(bcpow('-2', '5'));
var_dump(bcpow('-2', '5', 2));
?>
--EXPECT--
string(3) "-32"
string(5) "-32.00"

Expected result:
----------------
string(3) "-32"
string(5) "-32.00"

Actual result:
--------------
string(3) "-32"
string(3) "-32"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-09 07:37 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Type: Bug +Type: Documentation Problem -Package: BC math related +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2010-09-09 07:37 UTC] aharvey@php.net
It actually does influence the result, but libbcmath's bc_raise() function manipulates the scale internally for its own purposes, so you may end up with a result of lesser scale than the scale parameter would indicate. (It appears that you'll never end up with a result of greater scale, though.)

Morphing into a doc bug, since libbcmath itself appears to behave logically; I'll add a note to the bcpow() manual page that the result scale may not be quite what you expect.
 [2010-09-09 07:45 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=303202
Log: Fix (doc) bug #52748 (bcpow() - scale parameter doesn't influensce the result
string) by adding a clarifying note about bcpow's exact behaviour when dealing
with scale.
 [2010-09-09 07:45 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2010-09-09 07:45 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC