ID: 9248
Updated by: andre
Reported By: [EMAIL PROTECTED]
Old-Status: Closed
Status: Bogus
Bug Type: Math related
Assigned To:
Comments:
bogus
Previous Comments:
---------------------------------------------------------------------------
[2001-02-13 18:35:22] [EMAIL PROTECTED]
its the good old binary/decimal rounding issue
$result is internally something like e.g.14497.999999999998
when using plain echo rounding will be applied (see php.ini 'precision')
while sprintf "%d" does not round but will cut of all decimals
sprintf("%d",round($result)) should work find
---------------------------------------------------------------------------
[2001-02-13 18:21:22] [EMAIL PROTECTED]
Sometimes when trying to multiply a float and a int then print the result out with
sprintf there is a error in the computation.
The following code produces the incorrect output:
<?
$val1 = 144.98;
$result = ($val1 * 100);
echo $result . "n"; ## Correct output '14498'
echo sprintf ("%10dn", $result); ## Incorrect output '14497'
?>
Not sure if there is something obvious that I am missing? Any help would be
appreciated.
My config line:
./configure --with-mysql=/usr --with-apxs=/usr/sbin/apxs --with-gd=/usr/local
--enable-trans-sid --enable-track-vars --enable-bcmath --with-ttf
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9248&edit=2
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]