Wednesday, 21 August 2013

Does bit shift automatically promote chars to int?

Does bit shift automatically promote chars to int?

I read somewhere that bitwise shift automatically turns the operand into
an int. But I'm not sure if that statement should be qualified with "if
the operands are of unequal type."
char one = 1, bitsInType = 8;
one << (bitsInType - one);
Does the default result of the second line result in an int or char?

No comments:

Post a Comment