ID: 10002
Comment by: [EMAIL PROTECTED]
Old Reported By: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: Strings related
Operating System: RedHat 7.0
PHP Version: 4.0 Latest CVS (26/03/2001)
New Comment:

I'm sorry to say that I experienced similar misbehaviour
with  PHP 4.0.6 and 4.1.1, too. 

I'm pulling aggregated statistics from database and display
it. I'm currently working on minimize a test case, please wait. Till
then, visit this link:

http://213.134.22.60/~gerzson/sprintf.php

this is a very simple test script with a show_source() and 
phpinfo(). I think this bug should be reopened.


Previous Comments:
------------------------------------------------------------------------

[2001-03-27 12:30:21] [EMAIL PROTECTED]

Patch applied, but it's still a strange thing.

------------------------------------------------------------------------

[2001-03-27 08:32:14] [EMAIL PROTECTED]

I can't reproduce it under RH 6.2.  Generally the fix isn't supposed to
do anything (since arg is a double, 10 should be converted to a double
automatically), but the fix can't hurt anything so if it works around a
compiler bug, it's fine.

PHP cannot use sprintf() because sprintf() works with C types with
predefined types for the arguments, whether PHP has its own types, and
autoconverts arguments to match the format string.

------------------------------------------------------------------------

[2001-03-26 17:19:30] [EMAIL PROTECTED]

This bug is in 4.0.5RC2 too, just confirmed it

------------------------------------------------------------------------

[2001-03-26 14:13:27] [EMAIL PROTECTED]

<?php
printf('%.2f',0.09999999999999999167332731531132594682276248931884765625);
?>
produces '0.0:' instead of '0.10'

I'm really curious as to why PHP just doesn't use libc's sprintf().

./configure --with-oracle=/usr/local/oracle/product/8.1.7 \
  --with-oci8=/usr/local/oracle/product/8.1.7
--enable-force-cgi-redirect \
  --enable-track-vars --with-posix --enable-sockets --enable-sigchild
\
  --with-gd=/usr/local

gcc version 2.95.2 19991024 (release)


This is not exactly a fix...
--- ext/standard/formatted_print.c      Mon Mar 26 14:01:31 2001
+++ ext/standard/formatted_print.c-fixed        Mon Mar 26 14:02:26
2001
@@ -92,7 +92,7 @@
                while (p1 < &cvt_buf[NDIG])
                        *p++ = *p1++;
        } else if (arg > 0) {
-               while ((fj = arg * 10) < 1) {
+               while ((fj = arg * 10.0) < 0.9999999) {
                        arg = fj;
                        r2--;
                }



------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=10002&edit=1


-- 
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]

Reply via email to