php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53139 floating int not displayed correctly
Submitted: 2010-10-22 15:13 UTC Modified: 2013-02-18 00:34 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kpetre at excelmicro dot com Assigned:
Status: No Feedback Package: Strings related
PHP Version: 5.3.3 OS: win7
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
48 + 20 = ?
Subscribe to this entry?

 
 [2010-10-22 15:13 UTC] kpetre at excelmicro dot com
Description:
------------
I am developing a tool which parses header information etc. were using 5.3.1 and cant really upgrade at the snap of a finger due to management limitations. One line in the message is $levels.  This contains a bunch of floating point numbers which i will need to compare to other floating point numbers.  I have a table where this floating int is 'echoed'.  When it is echo'd, numbers to the left of the decimal appear as a symbol character. Once the page is refreshed, the numbers to the left of the decimal are displayed correctly. (real example '?.15998') as soon as its refreshed, 20.15998 is shown as expected.

I thought if i changed the $scorefinal back to a string it would resolve but it does the same thing.  Any thoughts?

Test script:
---------------
echo $levels;   //$levels= (S:20.15998/99.90000 CV:99.9000 FC:95.5390 LC:93.6803 R:95.9108 P:95.9108 M:97.0282 C:60.2565 )..



$scorefinal = strstr($levels,"S:");
$scorefinal = strstr($scorefinal,"/",true);
$scorefinal = substr($scorefinal,2);    
//echo $scorefinal;                        //this now is a string and is 20.15998
$scorefinal = 0 + $scorefinal;             //convert to float
$scorefinal2 = "$scorefinal";              //20.15998 is now a string again

Expected result:
----------------
I expect to see the full floating int every-time the page is called.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-23 23:44 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2010-10-23 23:44 UTC] pajoye@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2010-10-27 19:36 UTC] kpetre at excelmicro dot com
-Status: Feedback +Status: Open
 [2010-10-27 19:36 UTC] kpetre at excelmicro dot com
<?php

$stringstart = "91.65894";  #initally i get these numbers as strings
$converttofloat = 0 + $stringstart; # i convert them to float by doing this

$vartype = gettype ($converttofloat);

echo $converttofloat . " is this type of variable: " . $vartype;

?>
 [2010-10-30 02:58 UTC] cataphract@php.net
-Status: Open +Status: Feedback
 [2010-10-30 02:58 UTC] cataphract@php.net
That script here outputs:

"91.65894 is this type of variable: double"

What do you get?
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC