473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Converting a float to a string

Hello,

float.parse(MyString)

seems to work to convert a string to a float, but how do I change it
back?

e.g.

(string) (Myfloat1 - Myfloat2)

doesn't seem to work.

Mar 17 '06 #1
5 2456
myFloat.ToString() should do it..

Mar 17 '06 #2
You can call the ToString method on the float.
http://msdn.microsoft.com/library/de...tringtopic.asp

--
Tim Wilson
..NET Compact Framework MVP

<er**********@gmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...
Hello,

float.parse(MyString)

seems to work to convert a string to a float, but how do I change it
back?

e.g.

(string) (Myfloat1 - Myfloat2)

doesn't seem to work.

Mar 17 '06 #3
Thanks, that works. The intellisense seems to choke on it though:

float float1;
float float2;

string mystring;

mystring=(float1-float2).ToString();

When I type the "." after (float1-float2) I don't see a list of
methods.

If I type in ".ToString();" manually it seems to compile though.

-Eric

Mar 17 '06 #4
Yeah. Intellisense does not like to show options in this situation, I guess.
I've noticed that too. But, as you said, it's valid and the compiler handles
it as it should.

--
Tim Wilson
..NET Compact Framework MVP

<er**********@gmail.com> wrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
Thanks, that works. The intellisense seems to choke on it though:

float float1;
float float2;

string mystring;

mystring=(float1-float2).ToString();

When I type the "." after (float1-float2) I don't see a list of
methods.

If I type in ".ToString();" manually it seems to compile though.

-Eric

Mar 17 '06 #5
just : float myFloat = float1-float2;
string str;
str = myFloat.ToString();
that's ok.
---
Posted via www.DotNetSlackers.com
Mar 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Bushido Hacks | last post by:
Hey c.l.c++ and/or c.g.a.opengl posters, How do I convert a hexidecimal string, traditionally used for defining colors with HTML, into a floating point array? In other words, how do I convert...
1
by: Meya-awe | last post by:
Hello there, I am using a 3rd party library and a function which requires a float value in one of its methods. My data is in a string format and i tried using Convert.ToDouble and...
5
by: vivekaseeja | last post by:
Hi , Trying to convert a string value to a float value after reading the value from an XML file , but not sure what function to use. The following only works for integers Int32.Parse...
3
by: Jim Langston | last post by:
I have a CSkill class which is rather complex as it is recursive. That is: class CSkill { public: CSkill( std::string Name, float Value ): Name_( Name ), Value_( Value ) {}; void Update(...
3
by: pipe.jack | last post by:
I'm trying to convert string to float and my float after conversion is 0 (zero). Here is my code: $c = $currencies->format($cart->show_total()); echo gettype($c); echo (float)$c; $c = 39.59...
3
by: psbasha | last post by:
Hi , When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ). ...
12
by: joestevens232 | last post by:
Okay, Im having some problems with my code. Im trying to use the <cstdlib> library and im trying to convert string data at each whitespace slot. I think if you see my code you'll get what im trying...
10
by: Hank Stalica | last post by:
I'm having this weird problem where my code does the following conversion from string to float: 27000000.0 -27000000.00 2973999.99 -29740000.00 2989999.13 -2989999.25 The number on the left...
7
by: DirtyRasa | last post by:
Here is what my professor told me to to. Write a function that converts a string to a float and returns a float. Test your function by entering f4 and with 4f. Both should say Data entered was...
7
by: ma740988 | last post by:
Consider the equation (flight dynamics stuff): Yaw (Degrees) = Azimuth Angle(Radians) * 180 (Degrees) / 3.1415926535897932384626433832795 (Radians) There's a valid reason to use single...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.