Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
How can I use float.Parse to get the text representing the result (after parsing) written in static point form. For example, I have a string like "100000000." (8 zeroes with a point at the end). I want float.Parse("100000000.").ToString() to be "100000000" (remove the point). But in fact, it returns "1E+08".
How can I get what I want? I know the values are the same, but the strings representing them are not.
Thank you so much!
Posted

In addition to Steve's Solution.

Learn some of data formatting used in object.ToString and string.Format methods.
Start here: http://msdn.microsoft.com/en-us/library/26etazsy.aspx[^].

—SA
 
Share this answer
 
Comments
[no name] 17-Apr-11 13:50pm    
Thank you! My 5.0 for you! I just want more but 5 is maximum!
Sergey Alexandrovich Kryukov 17-Apr-11 14:05pm    
You're welcome.
(But what's so special? you could find it next to your ToString help...)
Thanks for accepting this Question.

Good luck, call again.
--SA
Tarun.K.S 17-Apr-11 13:57pm    
Wow I needed it! Thanks SA!
Sergey Alexandrovich Kryukov 17-Apr-11 14:05pm    
Thank you :-)
--SA
That just happens to be the default display format in the debugger. You can format a floating point number anyway you want:

C#
float x = float.Parse("100000000.");
String Test1 = x.ToString("#");
 
Share this answer
 
Comments
Tarun.K.S 17-Apr-11 9:45am    
Good answer. +5
[no name] 17-Apr-11 10:32am    
Thank you so much!
My 5 for you!
Sergey Alexandrovich Kryukov 17-Apr-11 13:23pm    
Sure, a 5. I added a general direction to this answer, please see.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900