Casting uint32_t to int32_t and comparing them afterwards
问题 I'm having trouble understanding how does comparing two ints, where one is unsigned int32 and the other one signed int32 work. Let's consider this simple program: #include <stdint.h> int main() { uint32_t a1 = UINT32_MAX; int32_t b1 = (int32_t)a1; if (a1 == b1) printf("Equal"); else printf("Not equal"); return 0; } In this case, a1 exceeds a signed 32-bit integer range, so as I have confirmed while debugging, after it's been casted, b1 equals -1 . However it still prints "Equal", while those