Please before you think that I'm asking the same N% Question read it first and please pay Attention to it.
I'm working on a project where I have more functions which returns double and it may be possible that some of them are the same which is a good thing in my project and if is true then I need a double
comparison to see if are equal.
I know that doing an equality comparison if( x == y )
is not a smart thing and we don't need to speak why, but we can check for <
or >
which is the part of this Question.
Does the language (standard) guarantee this, that the comparison <
and >
are 100%?
If yes then, the following program can be used:
#include <stdio.h>
int main(void){
double x = 3.14;
double y = 3.14;
if( x < y || x > y){
/* Are not Equal */
}else{
/* Are Equal, foo() will be called here\n" */
foo(x, y);
}
}
Does foo(x, y);
get executed? BecauseX
and Y
should be equal here.
EDIT: This question doesn't seek a way to compare two double, it is only the fact that should I use, or should I don't use < > instead of ==