Signedness determines whether an integer type represents negative values. It also determines the type’s value range and affects how C evaluates expressions that combine integer types. section 5.4 section 5.7.1
The same comparison can change meaning
-1 < 0 // true, same signedness -1U < 0U // false, same signedness -1 < 0U // false, mixed signedness -1L < 0U // depends on platform The mixed cases convert operands before comparison. A negative signed value can therefore become a large unsigned value, while combinations involving different widths can depend on implementation ranges. section 5.4
Keep these distinctions in view:
- Unsigned integer arithmetic is determined by its precision; with p value bits, its maximum value has the form 2^p − 1. section 5.7.1
- Signed and unsigned types do not have strictly nested value ranges, so implicit conversion choices can produce surprising results. section 5.4
- Choose arithmetic types so implicit conversions are harmless, and avoid operations whose operands have different signedness. section 5.4
-1 < 0 // True, harmless, same signedness -1L < 0 // True, harmless, same signedness -1U < 0U // False, harmless, same signedness -1 < 0U // False, dangerous, mixed signedness -1U < 0 // False, dangerous, mixed signedness -1L < 0U // Depends, dangerous, same or mixed signedness -1LL < 0UL // Depends, dangerous, same or mixed signedness
Compare harmless same-signedness expressions with dangerous mixed-signedness cases, including platform-dependent outcomes. section 5.4

