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

 ID:                 53139
 Updated by:         cataphr...@php.net
 Reported by:        kpetre at excelmicro dot com
 Summary:            floating int not displayed correctly
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Strings related
 Operating System:   win7
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

That script here outputs:



"91.65894 is this type of variable: double"



What do you get?


Previous Comments:
------------------------------------------------------------------------
[2010-10-27 19:36:36] 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-23 23:44:42] paj...@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-22 15:13:48] 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.



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



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

Reply via email to