Home > Back-end >  AnsiString. ToDouble () numerical comparison problem, and please help to see, feel grateful!
AnsiString. ToDouble () numerical comparison problem, and please help to see, feel grateful!

Time:09-29

The HTML code is as follows, executes m_num & lt; M_str. ToDouble () returns the result is true, best can not, please explain greatly,
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# include & lt; The VCL. H>
# include & lt; stdio.h>
# pragma hdrstop

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# pragma argsused
Int main (int arg c, char * argv [])
{
AnsiString m_str="0.74";
Double m_num=0.74;
Double m_num2=m_str. ToDouble ();
If (m_num & lt; M_str. ToDouble ())
{
Printf (" ToDouble % 2 f & lt; % 2 f \ n ", m_num, m_str. ToDouble ());
}

If (m_num & lt; M_num2)
{
Printf (" % 2 f & lt; % 2 f \ n ", m_num, m_num2);
}

System (" PAUSE ");
return 0;
}

CodePudding user response:

The results should be this also

CodePudding user response:

You change which is a step in the right
If (m_num & lt; M_num2)
Caption=1;
The else
Caption="2";

CodePudding user response:

refer to the second floor ksrsoft response:
you change which is a step in the right
If (m_num & lt; M_num2)
Caption=1;
The else
Caption="2";


To ask, why can't use this way to determine if (m_num & lt; M_str. ToDouble ())?

CodePudding user response:

Really strange, the estimate is a bug
  • Related