IT Community - Software Programming, Web Development and Technical Support

Convert float to string

This is a discussion on Convert float to string within the C# Programming forums, part of the Software Development category; Hi, I think most of us intially will stuck a little bit to convert string to float.Here is the ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-24-2007, 01:32 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Convert float to string

Hi,
I think most of us intially will stuck a little bit to convert string to float.Here is the coding to convert string to float.

float resultValue= float.Parse(string _value);

Cheers
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-25-2007, 03:57 AM
Sundaram Sundaram is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Location: chennai
Posts: 117
Sundaram is on a distinguished road
Send a message via MSN to Sundaram Send a message via Yahoo to Sundaram
Question Re: Convert float to string

Hi buddy,

U hv started ur thread as "Convert Float to String". But u explained about String to float....(smile)

ok..I hv one doubt..if u can, clear me...

I'm going to convert my string to float as follows(as ur way).

Code:
string s = "141781.23";
float f = float.Parse(s);
but I got the float value as ...f=141781.234,

I need the exact figure...why this is happening....

help me....

Regards,
M.Sundaram.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-26-2007, 11:09 PM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: Convert float to string

You can use double for float. Double better for ur query bcoz floats in c# are only precise to 7 digits…

So use System.Convert.ToDouble(string stringValue)….

From ur code use this…

string s = "141781.23";
double d = double.Parse(s);
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert String to Date: new Date(string) oxygen Flash Actionscript Programming 3 03-07-2008 09:24 PM
convert a text string into a Date object. itbarota HTML, CSS and Javascript Coding Techniques 2 02-12-2008 06:37 AM
How do I convert a Number into a String with exactly 2 decimal places? itbarota HTML, CSS and Javascript Coding Techniques 2 10-26-2007 05:22 AM
Need Help: convert string to unknown class object c#? a.deeban C# Programming 0 08-16-2007 05:18 AM
convert ordinary string into XML Jeyaseelansarc HTML, CSS and Javascript Coding Techniques 0 08-14-2007 03:18 AM


All times are GMT -7. The time now is 10:43 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0