php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31026 Problem with type conversion
Submitted: 2004-12-08 20:37 UTC Modified: 2004-12-20 13:34 UTC
From: tobi at knmm dot de Assigned:
Status: Closed Package: Variables related
PHP Version: 4.3.10RC3-dev OS: Linux 2.6.8 (Debian sarge)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
30 + 1 = ?
Subscribe to this entry?

 
 [2004-12-08 20:37 UTC] tobi at knmm dot de
Description:
------------
A very strange problem occurs on my webserver. If you run the provided code via http://knmm.de/bug.php a few times, in about 1 out of 10 times the second line of output is "$price is a double with value 34". This shows up randomly.
Running the script on the commandline of the same machine doesn't show this behaviour.

--
Tobi

Reproduce code:
---------------
$price = '34.90';

echo "\$price is a ".gettype($price)." with value $price\n";
settype($price,'double');
echo "\$price is a ".gettype($price)." with value $price\n";

(also available via http://knmm.de/bug.phps)

Expected result:
----------------
$price is a string with value 34.90
$price is a double with value 34.9


Actual result:
--------------
$price is a string with value 34.90
$price is a double with value 34


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-18 00:52 UTC] tobi at knmm dot de
Now, with the CVS version the script says '34,9' instead of 34.9 (with 4.3.9 it was only '34').
This solves my problem, which was that calculations with variables, type-converted from string to float had gone wrong sometimes. 
But it's still very strange.
I figured out that the problem only occurrs if the apache webserver with php on it already ran for a few hours.
 [2004-12-20 13:34 UTC] sniper@php.net
Fixed -> closed.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC