If a signed integer is compared with an unsigned integer, the signed integer is interpreted as unsigned and the comparison is done as betwween unsigned values.
Example:
int x = -1; // 0xFFFFFFFF int y = 34; // 0x00000022 unsigned int u = 35; // 0x00000023 unsigned int v = 4026531840; // 0xF0000000
| Comparison | Computed as Signed or Unsigned |
1 (true) or 0 (false) |
|---|---|---|
| x < y | signed | 1 |
| u < v | unsigned | 1 |
| x < u | unsigned | 0 |
| x < v | unsigned | 0 |
| y < u | unsigned | 1 |
| y < v | unsigned | 1 |