#19189 [Opn]: sprintf yields wrong result
| From: | gwenzel at emb dot de | Date: | Fri, 30 Aug 2002 08:43:42 +0000 |
| Subject: | #19189 [Opn]: sprintf yields wrong result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-18229@lists.php.net to get a copy of this message | ||
ID: 19189
User updated by: gwenzel@emb.de
Reported By: gwenzel@emb.de
Status: Open
Bug Type: Variables related
Operating System: Linux Suse 7.1
PHP Version: 4.2.0
New Comment:
Ok. This might not be a bug in sprintf.
But why does
echo ( 68.85*100 ) yield 6885
and
echo ( intval ( 68.85*100 ) ) yield 6884 ?
And by the way my provider does not support PHP with the bcmath
extension
Previous Comments:
------------------------------------------------------------------------
[2002-08-30 04:43:41] gwenzel@emb.de
Ok. This might not be a bug in sprintf.
But why does
echo ( 68.85*100 ) yield 6885
and
echo ( intval ( 68.85*100 ) ) yield 6884 ?
And by the way my provider does not support PHP with the bcmath
extension
------------------------------------------------------------------------
[2002-08-30 03:32:51] sander@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Use the bcmath extension to avoid problems like these.
------------------------------------------------------------------------
[2002-08-30 03:20:42] gwenzel@emb.de
echo ( sprintf("%012d", 68.85*100 ) );
yields
000000006884
Strangly enough:
echo ( sprintf("%012d", 68.95*100 ) );
yields the correct result:
000000006895
'./configure' '--with-apxs=/usr/local/apache/bin/apxs'
'--enable-trans-sid' '--with-mysql' '--enable-ftp'
'--with-config-file-path=/www/conf' '--with-zlib-dir=/usr/local'
'--with-gd=/usr/local' '--with-png-dir=/usr/local'
'--with-jpeg-dir=/usr/local' '--with-freetype-dir=/usr/local'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19189&edit=1