Usual arithmetic conversions are a standardized set of implicit type conversion rules applied to the operands of most binary operators in C to yield a common type (which may be a real or complex type) for the operation and its result. These rules establish a strict hierarchy evaluated sequentially based on type domain, integer conversion rank, and signedness. Phase 1: Floating-Point Resolution The compiler first checks for floating-point types. If either operand has a floating-point type, the other operand is implicitly converted to match, and no integer promotions are performed:Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
- If either operand has type
long double(orlong double _Complex), the other operand is converted tolong double(or the corresponding complex type). - Otherwise, if either operand has type
double(ordouble _Complex), the other operand is converted todouble(or the corresponding complex type). - Otherwise, if either operand has type
float(orfloat _Complex), the other operand is converted tofloat(or the corresponding complex type).
int (such as char, signed char, unsigned char, or short), as well as bit-fields of type _Bool, int, signed int, or unsigned int, is promoted to int if int can represent all values of the original type. If int cannot represent all values, the operand is promoted to unsigned int.
Phase 3: Integer Resolution
After integer promotions, the compiler evaluates the promoted integer operands against the following rules, stopping at the first matching condition:
- Same Signedness: If both operands have the same signedness (both signed or both unsigned), the operand with the lesser integer conversion rank is converted to the type of the operand with the greater rank.
- Mixed Signedness (Unsigned Rank Dominates): If the operand with unsigned integer type has a rank greater than or equal to the rank of the type of the signed integer operand, the signed integer operand is converted to the type of the unsigned integer operand.
- Mixed Signedness (Signed Rank Dominates, Value Preserved): If the type of the signed integer operand can represent all of the values of the type of the unsigned integer operand, the unsigned integer operand is converted to the type of the signed integer operand.
- Mixed Signedness (Fallback): Otherwise, both operands are converted to the unsigned integer type corresponding to the type of the signed integer operand.
_Generic and _Static_assert to prove the resulting types at compile-time, including preprocessor conditionals to handle architecture-dependent integer resolutions:
Master C with Deep Grasping Methodology!Learn More





