New answers tagged

3

The rule in C++, which was inherited from C, is that all operands that are smaller than int or unsigned int are first converted to one of those (with int being preferred if it can represent all values of the original type) before the operation is performed. The type int (and unsigned int) is expected to match the native register size for non-floating-point ...


2

The C++ Language specification follows the C language specification in being counter-intuitive here. Its defined so that when evaluating integer expressions everything is first converted to an int and then the expression is evaluated. This also applies to unsigned values getting converted to signed values. My guess is that this behavior simplified compiler ...


Top 50 recent answers are included