|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-12-03 16:53 UTC] jm at wo dot cz
Description:
------------
Some float numbers are incorrectly converted to string values:
I found it by playing with eval and getting wrong results. Then I did:
echo floatval('3.86e-6'); // output: 3.86E-6
echo floatval('1.01e-6'); // output: 1.01E-6
But
echo floatval('1E-6'); // output: :.0E-7
But one can do:
$f=1E-6;
echo $f; // output: .0E-7
So it must be a problem with float to string conversion.
Reproduce code:
---------------
$f=1E-6;
echo $f; // output: :.0E-7
Expected result:
----------------
1.0E-6
Actual result:
--------------
:.0E-7
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 21:00:01 2025 UTC |
Interesting that you can't reproduce it, I did not expect that, otherwise I would have provided the build info. Nevertheless, I have just recompiled php and the bug is still there. The glibc is 2.3.6 and gcc is 4.2.1. Here is the build set up: PHP_CONFIGURE="\ --prefix=/usr \ --sysconfdir=/etc \ --with-config-file-path=/etc \ --disable-static \ --disable-debug \ --disable-rpath \ --enable-inline-optimization \ --enable-pic \ --enable-bcmath \ --enable-calendar \ --enable-magic-quotes \ --enable-track-vars \ --enable-safe-mode \ --enable-sysvsem \ --enable-sysvshm \ --enable-force-cgi-redirect \ --enable-trans-sid \ --enable-yp \ --enable-ftp \ --enable-wddx \ --enable-filepro \ --enable-dbase \ --with-versioning \ --with-gettext \ --with-mod_charset \ --with-layout=GNU \ --with-zlib \ --with-bz2 \ --enable-exif \ --with-regex=system \ --enable-mbstring=all \ --enable-mbregex \ --with-pspell \ --with-mhash \ --with-mcrypt \ --with-curl \ --with-gmp \ --with-openssl \ --with-pgsql=/usr \ --with-gdbm \ --with-xml --with-expat-dir=/usr \ --with-xsl \ --with-apxs2 \ --with-t1lib=/usr/share/t1lib \ --with-freetype-dir=/usr/lib \ --with-gd " ./configure $PHP_CONFIGURE