Bug #14966 Updated: round() function doesn't always work
| From: | derick@php.net | Date: | Mon, 01 Apr 2002 09:22:00 +0000 |
| Subject: | Bug #14966 Updated: round() function doesn't always work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-3724@lists.php.net to get a copy of this message | ||
ID: 14966
Updated by: derick@php.net
Reported By: rpb@community.net.uk
-Status: Open
+Status: Closed
Bug Type: *Math Functions
Operating System: Compaq Tru64 v4.0E
PHP Version: 4.0.6
New Comment:
Fixed in CVS, for both 4.2.x and 4.3.x
Derick
Previous Comments:
------------------------------------------------------------------------
[2002-01-10 09:54:39] rpb@community.net.uk
The same code is used in PHP 4.1.1, BTW.
------------------------------------------------------------------------
[2002-01-10 09:53:27] rpb@community.net.uk
If PHP is built without complete ANSI C prototypes in scope the 'round'
function can fail.
This is because the second argument to 'pow' in ext/standard/math.c:143
is an integer, and without prototypes it doesn't receive its implicit
cast to a double, causing the 'pow' function to receive an undefined
value on the stack.
The simple fix is to put an explicit (double) cast in:
f = pow(10.0, (double)places);
A better fix might be to ensure that the ANSI version of the prototypes
from <math.h> are always in scope, but that may be difficult to achieve
across a wide variety of systems.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=14966&edit=1