This seemingly trivial line is taken from the C book my Mike Banahan & Brady (Section 2.8.8.2).
I can understand how implicit promotion comes into play in expressions like c=a+b
depending on the types of the operands, but I am unable to grasp how and in which case the same can figure in something like -b
, where b is any legitimate operand. Can you explain it and then give a proper example?
Extracted text follows:
The usual arithmetic conversions are applied to both of the operands of the binary forms of the operators. Only the integral promotions are performed on the operands of the unary forms of the operators.
Update:
Lest it goes unnoticed, here I am adding what I asked based on OUAH's answer in a comment–
The book says 'Only the integral promotions are performed
'...Does it mean that in an expression like x=-y
, where 'x' is a long double and 'y' is a float, 'y' won't be promoted to long double if we explicitly use a unary operator? I know it would be, but asking it nevertheless to get a clearer idea about the "Only the integeral promotions..." part.
Update:
Can you explain with example how promotion comes into play for the following bit-wise operators? For the last three, should I assume that whenever those are used on a variable, it is promoted to integer type first? And what exactly does the "usual arithmetic conversions" mean for the first three? Can you give a small example? I don't want to post it as a separate question if it can be settled here.