In Steven Prata\'s book \"C Primer Plus\", there\'s a section on Type Conversions, wherein \"The basic rules are\" section has stated in rule 1:
Under K&R C,
Look at the entire rule:
When appearing in an expression,
char
andshort
, bothsigned
andunsigned
, are automatically converted toint
or, if necessary, tounsigned int
. (Ifshort
is the same size asint
,unsigned short
is larger thanint
; in that case,unsigned short
is converted tounsigned int
.) Under K&R C, but not under current C,float
is automatically converted todouble
. Because they are conversions to larger types, they are called promotions.
If we consider the integer types, when they appear in e.g. arithmetic expressions, they are still promoted, so no arithmetic is -theoretically - performed at the types char
or short
, but all at type int
, unsigned int
or a type with higher conversion rank (under the as-if rule, if the implementation can guarantee that the result is the same as if the promotion were actually carried out, it can perform arithmetic at smaller types if the platform provides the instructions).
The analogous used to hold for float
, under the old pre-standard rules, float
s were promoted to double
for all arithmetic etc.
That is no longer the case, arithmetic on float
s does not involve automatic promotion under standardised C.
In expressions with mixed types, generally everything is still promoted to the largest involved type, so if you compare or add a float
to a double
, the float
is converted to double
before the operation.