From: abajolet at toiletoine dot net
Operating system: Linux Mandrake 8.1
PHP version: 4.3.2
PHP Bug Type: Strings related
Bug description: printf/sprintf problem with %f and negative numbers
Hello.
I just discover strange behavior of printf/sprintf :
This code :
<?php
printf('%01.2f',0.2); print '<br>';
$test = sprintf('%01.2f',0.2);
print strlen($test).'<br>';
print ord(substr($test,-1)).'<br>';
printf('%01.2f',-0.2); print '<br>';
$test = sprintf('%01.2f',-0.2);
print strlen($test).'<br>';
print ord(substr($test,-1)).'<br>';
?>
Give me :
0.20
4
48
-0.20<invisible character there -> mozilla displays a square>
6
0
It seems that the bug #6192 is back !
With php 4.3.0, this bug did not appear, with exactly the same config but
php itself.
Compile options, both 4.3.0 and 4.3.2 :
./configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/etc \
--with-ming \
--with-ldap \
--with-mysql \
--with-pgsql \
--with-gd \
--with-jpeg-dir=../jpeg-6b \
--with-png-dir=../libpng-1.2.2 \
--with-freetype-dir=../freetype-2.1.0 \
--with-t1lib \
--enable-bcmath \
--enable-calendar \
--enable-trans-sid \
--with-mcrypt \
--with-mhash \
--with-regex=php \
--with-zlib \
--enable-ftp \
--with-openssl \
--with-snmp \
--enable-ucd-snmp-hack \
--enable-sockets \
--enable-track-vars \
--enable-magic-quotes \
--enable-xslt \
--with-xslt-sablot \
--with-iconv=/usr/local \
--enable-sigchild \
--enable-inline-optimization
Best regards,
Antoine Bajolet
--
Edit bug report at http://bugs.php.net/?id=23921&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23921&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23921&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23921&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23921&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23921&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23921&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23921&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23921&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23921&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23921&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23921&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23921&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23921&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23921&r=gnused