ID:               43487
 User updated by:  jm at wo dot cz
 Reported By:      jm at wo dot cz
-Status:           Feedback
+Status:           Open
 Bug Type:         Strings related
 Operating System: Linux
 PHP Version:      5.2.5
 New Comment:

I got the same problem on another machine too, again PHP 5.2.5 with 
pretty much the same configuration. In fact, the problem exhibits 
also for version 5.2.4 on my machines.

About the unknown configuration options: Thanks, I had seen the 
warning but did not have the time to edit my scripts and based on 
the message it seemed harmless to leave the options be for now.

I am thinking that the problem and your inability to reproduce it 
could be due to some libraries that PHP uses that may be buggy in 
the versions on my systems. Can you please tell me what libraries, 
if any, to look for? Although the installed version of software are 
generally the latest stable releases, it is possible that a patch or 
a downgrade may be in order on some library/tool.

Finally, the problem has so far appeared for 3 numbers only: 
$ php -n -r '$f=array(1E-4, 1E-5, 1E-6, 1E-7, 1E-8); foreach ($f as 
$fval) echo $fval, "\n";'
0.0001
1.0E-5
:.0E-7
:.0E-8
1.0E-8


Jan


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

[2007-12-04 12:33:38] [EMAIL PROTECTED]

I can't reproduce either:

]# php -r '$f=1E-6; echo $f, "\n";'
1.0E-6

And pretty much the same configure options.
btw. Many of the options you used don't even exist, did you pay
attention to the last lines of the output after running configure?
(it warns you about unknown options)

Try this yourself:
# php -n -r '$f=1E-6; echo $f, "\n";'

(-n makes sure you don't use any php.ini which might have different
precision set)

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

[2007-12-03 19:17:07] jm at wo dot cz

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

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

[2007-12-03 18:41:25] [EMAIL PROTECTED]

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


Floats might be imprecise... they shouldn't be wrong. I can't reproduce
this though.

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

[2007-12-03 16:53:25] 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


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


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

Reply via email to