PHP 4.0 Bug #9248: float,int multiplication problem when using sprintf
| From: | mike at meltmedia dot com | Date: | Tue, 13 Feb 2001 23:21:22 +0000 |
| Subject: | PHP 4.0 Bug #9248: float,int multiplication problem when using sprintf | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46526@lists.php.net to get a copy of this message | ||
From: mike@meltmedia.com
Operating system: Redhat 6.2
PHP version: 4.0.4pl1
PHP Bug Type: Math related
Bug description: float,int multiplication problem when using sprintf
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 ("%10d\n", $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
--
Edit Bug report at: http://bugs.php.net/?id=9248&edit=1