[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Converting to float

Posted on 2009-12-24
10
Medium Priority
?
261 Views
Last Modified: 2012-05-08

                        personal.Longitude = City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Latititude"].;
                        personal.Longitude = City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Longitude"];

I need make this a float.

0
Comment
Question by:mathieu_cupryk
  • 5
  • 3
  • 2
10 Comments
 
LVL 11

Accepted Solution

by:
ICaldwell earned 800 total points
ID: 26121317
example from what you had....

personal.Longitude = (float)City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Latititude"];
personal.Longitude = (float)City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Longitude"];

Hope this helps....
double myDouble = 2006;
float myFloat = 0;
myFloat = (float)myDouble;

Open in new window

0
 

Author Comment

by:mathieu_cupryk
ID: 26121319
nope.
0
 
LVL 5

Assisted Solution

by:Laindow
Laindow earned 1200 total points
ID: 26121320
Hi,
 You need to use class Convert
Sample
             float myValue = Convert.ToSingle("12.15");
            double myValue2 = Convert.ToDouble("12.15");
Plz be sure what your number have correct format or that class will generate exception.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:mathieu_cupryk
ID: 26121322
 profile.Personal.Latitude = (float)Convert.ToDecimal(City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Latitude"].ToString());
            profile.Personal.Longitude= (float)Convert.ToDecimal(City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Longitude"].ToString());
0
 
LVL 11

Assisted Solution

by:ICaldwell
ICaldwell earned 800 total points
ID: 26121330
yes you can do it that way, that will work... there are several ways to do it.....
0
 

Author Comment

by:mathieu_cupryk
ID: 26121333
can u check if I loose precision.
0
 
LVL 5

Assisted Solution

by:Laindow
Laindow earned 1200 total points
ID: 26121348
Hi,
 Why are you convert to Decimal ? float that ToSingle you do double conversion.
0
 

Author Comment

by:mathieu_cupryk
ID: 26121355
profile.Personal.Latitude =  float.Parse(City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Latitude"].ToString());
            profile.Personal.Longitude = float.Parse(City.GetCitys(ddlCountryRegister.SelectedValue, ddlRegion.SelectedValue, "omegaloveConnectionString").Tables[0].Columns["Longitude"].ToString());
0
 
LVL 5

Assisted Solution

by:Laindow
Laindow earned 1200 total points
ID: 26121364
Hm, that's better - do same things like Convert. Like mathieu_cupryk said before a lot of ways to convert in C#.
0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31669895
k
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question