CKTIS / C
Equality operator ==
The == operator tests operands for equality. Its result has type int: 1 means equal, and 0 means unequal.
Version: C23; repository compiler flag, production runtime not attested
Syntax
left == rightleft == right tests equality; = assigns a value. The result of == is an int: either 1 or 0. The != operator tests inequality.
Arithmetic operands undergo the usual arithmetic conversions. Mixing signed and unsigned types can therefore be surprising. Floating-point equality is exact, not approximate.
Certain pointer comparisons are also permitted, including comparisons with a null pointer constant or C23 nullptr. Pointers do not compare string contents. Structures and unions cannot be compared directly with ==.
Writing a == b == c means (a == b) == c, not a three-way equality test. Use a == b && b == c.
Examples
#include <stdio.h>
int main(void)
{
int value = 7;
int *ptr = &value;
printf("%d %d %d\n", value == 7, value == 8, ptr == &value);
return 0;
}
Result
1 0 1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.