Till now I was believing that there is no use of unary +
operator.
But then I came across with following example:
char ch;
short sh;
in
When smaller types are involved in an expression with larger types (for example, char
is smaller than short
which mostly is smaller than int
which may be smaller than long
), the involved types are promoted to the larger tyoes.
So yes, when you use the unary +
operator, you get an int
, because int
is the natural integer type in C.
Regarding the double
type, the natural floating point type for C is double
, which is why there's no promotion on values or variables that already are of type double
.
The sizeof
operator have nothing to do with this.