tags:

views:

35

answers:

1

Hi guys, I am having the strangest problem...When I convert from a textbox->text into a double , I get the number .99999999991 if a zero was in the text box. Why is this? Here is my example code:

double theNumber = 0;

if( !double::TryParse( mTheText->Text, theNumber ) )
{
    return false;
}

Notice that double is set to zero at the start and is later set to .99999999991 after the tryparse is called. I use this exact code elsewhere and it works fine. What is happening here? Thanks.

A: 

Have you tried initializing theNumber to 0.0 instead of 0?

samandmoore
Resolved. There is no parser issue. Someone had mixed the names of the text boxes up.
I was unable to comment on your post so I had to post my response as an answer. `I use this exact code elsewhere and it works fine.` the exact code, including getting the string to be parsed from a textbox?EDIT: great!
samandmoore