Click here to Skip to main content
15,924,036 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionEvaluation order in an 'if' statement Pin
piul6-Jun-08 0:55
piul6-Jun-08 0:55 
AnswerRe: Evaluation order in an 'if' statement Pin
Cedric Moonen6-Jun-08 1:03
Cedric Moonen6-Jun-08 1:03 
AnswerRe: Evaluation order in an 'if' statement Pin
toxcct6-Jun-08 1:36
toxcct6-Jun-08 1:36 
AnswerRe: Evaluation order in an 'if' statement Pin
David Crow6-Jun-08 3:03
David Crow6-Jun-08 3:03 
AnswerRe: Evaluation order in an 'if' statement Pin
Mark Salsbery6-Jun-08 5:44
Mark Salsbery6-Jun-08 5:44 
Questionfloating point Pin
nitin36-Jun-08 0:51
nitin36-Jun-08 0:51 
AnswerRe: floating point Pin
Cedric Moonen6-Jun-08 0:57
Cedric Moonen6-Jun-08 0:57 
AnswerRe: floating point Pin
Nibu babu thomas6-Jun-08 1:00
Nibu babu thomas6-Jun-08 1:00 
nitin3 wrote:
//in the above code c does not contain the the result i expected , it filled with 5.099999 and i get the output Not OK.
how i can check the value of c ? please help me


Try this... works for me...

void main()
{
  float a = 5.0f , b = 0.1f ;
  float c = a + b;
 
  if( c >= 5.1f )
  {
    printf( "OK" ) ;
  }
  else
  {
    printf( "Not OK" ) ;
  }
}

Always append "f" to a float value else it's treated as a double, earlier you were comparing a float var and a double var.

Explained further -> http://nibuthomas.wordpress.com/2007/06/08/comparing-two-float-values/[^]


Nibu thomas
Microsoft MVP for VC++


Code must be written to be read, not by the compiler, but by another human being.

Programming Blog: http://nibuthomas.wordpress.com

AnswerRe: floating point Pin
Kwanalouie6-Jun-08 2:54
Kwanalouie6-Jun-08 2:54 
GeneralRe: floating point Pin
David Crow6-Jun-08 3:05
David Crow6-Jun-08 3:05 
AnswerRe: floating point Pin
Alan Balkany6-Jun-08 4:03
Alan Balkany6-Jun-08 4:03 
QuestionTo create status bar Pin
KASR16-Jun-08 0:45
KASR16-Jun-08 0:45 
AnswerRe: To create status bar Pin
Hamid_RT6-Jun-08 0:57
Hamid_RT6-Jun-08 0:57 
Question[Message Deleted] Pin
Trupti Mehta5-Jun-08 23:54
Trupti Mehta5-Jun-08 23:54 
AnswerRe: Reset an object dynamically Pin
Cedric Moonen6-Jun-08 0:08
Cedric Moonen6-Jun-08 0:08 
AnswerRe: Reset an object dynamically Pin
CPallini6-Jun-08 0:11
mveCPallini6-Jun-08 0:11 
QuestionSend a email Pin
john56325-Jun-08 23:53
john56325-Jun-08 23:53 
AnswerRe: Send a email Pin
tasumisra6-Jun-08 0:07
tasumisra6-Jun-08 0:07 
QuestionRe: Send a email PinPopular
Michael Schubert6-Jun-08 0:16
Michael Schubert6-Jun-08 0:16 
JokeRe: Send a email Pin
Hamid_RT6-Jun-08 1:18
Hamid_RT6-Jun-08 1:18 
GeneralRe: Send a email Pin
tasumisra6-Jun-08 1:34
tasumisra6-Jun-08 1:34 
GeneralRe: Send a email Pin
Hamid_RT6-Jun-08 1:43
Hamid_RT6-Jun-08 1:43 
QuestionRe: Send a email Pin
CPallini6-Jun-08 0:08
mveCPallini6-Jun-08 0:08 
AnswerRe: Send a email Pin
john56326-Jun-08 0:40
john56326-Jun-08 0:40 
GeneralRe: Send a email Pin
tasumisra6-Jun-08 0:46
tasumisra6-Jun-08 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.