[Main]
Title=Equality operators ('==' and '!=')
Index===, !=

[Top]
The operators <CODE>'=='</CODE> and <CODE>'!='</CODE> are used to test for equality or inequality between
arithmetic or pointer values, following rules similar to those for the relational operators.
However, the equality operators have lower precedence than the relational operators,
and you can also compare certain pointer types not allowed with relational operations.
<BR><BR>
In the expressions <I>expr1</I>&nbsp;==&nbsp;<I>expr2</I> and <I>expr1</I>&nbsp;!=&nbsp;<I>expr2</I>, the operands must conform to one
of the following sets of conditions:
<OL>
<LI>
Both <I>expr1</I> and <I>expr2</I> are of arithmetic type.
</LI>
<LI>
Both <I>expr1</I> and <I>expr2</I> are pointers to qualified
or unqualified versions of compatible types.
</LI>
<LI>
One of <I>expr1</I> and <I>expr2</I> is a pointer to an
object, and the other is a pointer to a qualified or unqualified version of void.
In this case, the pointer to an object is converted to the type
of the other operand (a void pointer).
</LI>
<LI>
One of <I>expr1</I> or <I>expr2</I> is a pointer and the other is a null pointer constant.
</LI>
</OL>
If <I>expr1</I> and <I>expr2</I> have types that are valid operand types for a relational
operator, the same comparison rules as for the relational operators apply.
<BR><BR>
If <I>expr1</I> and <I>expr2</I> are pointers to function types, <I>expr1</I>&nbsp;==&nbsp;<I>expr2</I> gives 1 (true) if they
are both null or if they both point to the same function.
Conversely, if <I>expr1</I>&nbsp;==&nbsp;<I>expr2</I> gives 1 (true), then either <I>expr1</I> and <I>expr2</I> point to the
same function, or they are both null.
<BR><BR>
The expression <I>expr1</I>&nbsp;!=&nbsp;<I>expr2</I> follows the same rules, except that the result is 1
(true) if the operands are unequal, and 0 (false) if the operands are equal.
<BR><BR>
Floating point comparisons are internally executed using the
<A HREF="$$LINK(timath.h/fcmp)">fcmp</A> function. See the description of this function for
more info about rules of comparisons for floating point values.
