Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2005

Tip: Looking for answers? Try searching our database.

Converting float in C to C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Meya-awe - 30 Sep 2005 08:17 GMT
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 Convert.ToSingle, but didn't work either way.
The value of string is "-57475.4531". The help in VS .NET 2003 tells me
that these convert methods will return double and single precision float
point values respectively but i needed to also cast the return to the
float type to make the compiler happy.  First how do i correctly convert
a string to a float?  As a side note, it does not makes sense to expose
the poor programmer to float in C and C++ and then take that and hide it
without explaining it somewhere. So, to give the benefit of doubt, the
explanation must be somewhere i have not come across. Any help will be
appreciated.
thanks,
BRAMOIN
Maqsood Ahmed - 30 Sep 2005 08:52 GMT
Hello,
 I tried float f = Convert.ToSingle("-57475.4531"); and it compiled
alright. I have also tried f.GetType().FullName and it displayed
System.Single. Tried same for the ToDouble and got System.Double as a
result.
Can you please share the code snippet. It'll help to understand the
problem.

Cheers.
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.