php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10116 bcpow treats second argument as integer
Submitted: 2001-04-02 09:29 UTC Modified: 2001-08-07 14:20 UTC
From: dan dot polansky at seznam dot cz Assigned:
Status: Not a bug Package: BC math related
PHP Version: 4.0.4pl1 OS: Windows 98
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:
MUST BE VALID
Solve the problem:
48 + 46 = ?
Subscribe to this entry?

 
 [2001-04-02 09:29 UTC] dan dot polansky at seznam dot cz
Function bcpow is supposed to work with arbitrary precision
numbers. However, it seems to treat its second argument
as an integer.

E.g.

echo bcpow(256,0.5);
echo bcpow(256,0.99);

both produce 1. It seems that the second argument is
truncated down to integer value. Either this is a
"feature" and documentation must be changed or it is
a bug of either Windows version or even other versions
of BCMath/PHP.

bcpow(0.5,2); produces 0.25, which is all right. 

Regards,
-- Dan

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-07 13:21 UTC] jmcastagnetto@php.net
This is an issue w/ the bcmath library itself, not a PHP bug. If you look in

ext/bcmath/libbcmath/src/raise.c

you'll see that in the function bc_raise(), the exponent is coherced to a long, and the comments says:

/* Raise NUM1 to the NUM2 power.  The result is placed in RESULT.
   Maximum exponent is LONG_MAX.  If a NUM2 is not an integer,
   only the integer part is used.  */

Suggest submitting as a bug to the author of bcmath (if you think it is a bug):  philnelson@acm.org 

Check also the definition of BC numbers in POSIX, the FAQ for bcmath, and the Unix/Linux command bc
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC