Advertisement

05.07.2008 at 11:51AM PDT, ID: 23383879
[x]
Attachment Details

Converting String to Float Problem with getting correct decimal places

Asked by jholmes724 in C# Programming Language, .NET, Programming for ASP.NET

Tags: c#, IE7

I am using a text box to capture a percentage value.  Example.   .95676

I am using the following code to parse the string into a floating point number.
string pctValue = txtPctValue.txt  // Get value from textbox
Float pctFloat = float.parse(pctValue)  // Parse string into float variable

The problem is the value of pctFloat variable is something like  .9567694567

It seems to want to add its own decimal place assingments.

My Question is:  
How to you control the number of decimal places when converting a string to a float.  This is important as the calculations I have to use from this data is critical that it be accurate.  Any help is appreciated.Start Free Trial
[+][-]05.07.2008 at 12:07PM PDT, ID: 21519397

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, .NET, Programming for ASP.NET
Tags: c#, IE7
Sign Up Now!
Solution Provided By: NickWalt
Participating Experts: 4
Solution Grade: A
 
 
[+][-]05.07.2008 at 12:07PM PDT, ID: 21519398

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.07.2008 at 12:10PM PDT, ID: 21519431

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.07.2008 at 12:13PM PDT, ID: 21519453

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.07.2008 at 12:19PM PDT, ID: 21519508

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.07.2008 at 12:49PM PDT, ID: 21519755

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628