php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45117 strval gives :.0E-7 for 1e-6
Submitted: 2008-05-28 13:24 UTC Modified: 2008-07-23 14:10 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: rudolphi at chemie dot uni-kl dot de Assigned: fb-req-jani (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.6 OS: Ubuntu 8.04 (32bit)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rudolphi at chemie dot uni-kl dot de
New email:
PHP Version: OS:

 

 [2008-05-28 13:24 UTC] rudolphi at chemie dot uni-kl dot de
Description:
------------
When converting a number in exponential format with negative exponent of n=6,7,... strval (or implicit conversion to string) gives :.0E-(n+1) if there is no fractional part present. The error can be found both in the precompiled PHP 5.2.4 and self-compiled 5.2.6, but it cannot be reproduced under Windows or under PHP 5.2.3 Ubuntu 7.10 (64bit). Seems to be closely related to OS (?).

Reproduce code:
---------------
$float=1e-6;
echo strval($float);

Expected result:
----------------
1e-6 or 1.0e-6

Actual result:
--------------
:.0E-7

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-15 21:11 UTC] jani@php.net
I can not reproduce this, check this out:

# uname -a
Linux linux5 2.6.20-1.2944.fc6 #1 SMP Tue Apr 10 17:46:00 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
# php -n -r '$float=1e-6; var_dump($float, strval($float));'
float(1.0E-6)
string(6) "1.0E-6"
# php -v
$ php -v
PHP 5.2.7-dev (cli) (built: Jul 15 2008 04:32:33)
..

Can you post the same here?

 [2008-07-15 22:17 UTC] rudolphi at chemie dot uni-kl dot de
$ uname -a
Linux rudolphi 2.6.24-19-generic #1 SMP Wed Jun 18 14:43:41 UTC 2008 i686 GNU/Linux
$ php -n -r '$float=1e-6; var_dump($float, strval($float));'
float(:.0E-7)
string(6) ":.0E-7"
$ php -v
PHP 5.2.6 (cli) (built: May 29 2008 10:18:45) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
 [2008-07-16 10:00 UTC] jani@php.net
I can't reproduce in 32bit linux either:

$ uname -a
Linux localhost.localdomain 2.6.25.9-76.fc9.i686 #1 SMP Fri Jun 27 16:14:35 EDT 2008 i686 i686 i386 GNU/Linux
[jani@localhost ~]$ src/build/php_5_2/sapi/cli/php  -n -r '$float=1e-6; var_dump($float, strval($float));'
float(1.0E-6)
string(6) "1.0E-6"

 [2008-07-16 10:10 UTC] jani@php.net
I tried with non-debug build too and still can't reproduce.
What GCC version do you use..? Glibc?
 [2008-07-16 13:23 UTC] rudolphi at chemie dot uni-kl dot de
My GCC-Version is 4.2.3-1ubuntu6, libgcc1 is 4.2.3-2ubuntu7 and my libc6 is 2.7-10ubuntu3 (the up-to-date-versions of Hardy Heron). Thanks a lot for your efforts in this topic. I have just recompiled PHP 5.2.6 (and restarted apache) to reproduce the error with the very versions mentioned above. The error is still there.
 [2008-07-16 19:18 UTC] jani@php.net
Are you able to reproduce this on some other machine? Or some other *nix / linux distro? Or does it only happen with on one single machine and OS?
 [2008-07-17 15:02 UTC] rudolphi at chemie dot uni-kl dot de
The error can be reproduced on two different machines:
- my development machine (Core Duo 2300, 1GB) and
- the production machine (Core 2 Quad 9450, 2GB),
both running the 32bit version of Ubuntu 8.04 (including all updates, but no "proposed","backports" stuff)

I cannot reproduce the error on 
- another testing machine (Core 2 Duo 6550, 2GB) running Ubuntu 7.10 64bit
- a Windows 2003 Server
- a Win XP Professional running Xampp

I will try with some *nix-live cds and post the results very soon.
 [2008-07-17 16:02 UTC] rudolphi at chemie dot uni-kl dot de
On openSUSE 11, the problem cannot be reproduced either. Though, changing everything to openSUSE is not an option for me, sorry (usability is a nightmare). Isn't there any Ubuntu user out there who can reproduce this?
 [2008-07-20 11:16 UTC] jani@php.net
What gcc version that openSuSE has? Try this on the ubuntus: 

Using fresh, just untarred/gunzipped php sources:

# ./configure --disable-all --disable-cgi --enable-debug
# make
# php -n -r '$float=1e-6; var_dump($float, strval($float));'

 [2008-07-23 08:30 UTC] lmalgras at tennaxia dot com
It seems to be the same issue as reported on #43487
 [2008-07-23 08:59 UTC] rudolphi at chemie dot uni-kl dot de
Yes, I have just read #43487, and this seems to be my problem. I wonder why I did not find that one when searching for related information. Sorry, and thank you all for your help!!
 [2008-07-23 14:10 UTC] jani@php.net
Bogusing this since bug #43487 has lot more information.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 12:01:32 2024 UTC