
14 Expressions
14.8 Shift operators
Paragraph 11 The << and >> operators are used to perform bit shifting operations. shift-expression : additive-expression shift-expression << additive-expression shift-expression >> additive-expression
Paragraph 21 For an operation of the form x << count or x >> count, binary operator overload resolution (§14.2.4) is applied to select a specific operator implementation. 2 The operands are converted to the parameter types of the selected operator, and the type of the result is the return type of the operator.
Paragraph 31 When declaring an overloaded shift operator, the type of the first operand must always be the class or struct containing the operator declaration, and the type of the second operand must always be int.
Paragraph 41 The predefined shift operators are listed below. int operator <<(int x, int count); uint operator <<(uint x, int count); long operator <<(long x, int count); ulong operator <<(ulong x, int count);3 The << operator shifts x left by a number of bits computed as described below. 4 The high-order bits outside the range of the result type of x are discarded, the remaining bits are shifted left, and the low-order empty bit positions are set to zero.
int operator >>(int x, int count); uint operator >>(uint x, int count); long operator >>(long x, int count); ulong operator >>(ulong x, int count);6 The >> operator shifts x right by a number of bits computed as described below. 7 When x is of type int or long, the low-order bits of x are discarded, the remaining bits are shifted right, and the high-order empty bit positions are set to zero if x is non-negative and set to one if x is negative. 8 When x is of type uint or ulong, the low-order bits of x are discarded, the remaining bits are shifted right, and the high-order empty bit positions are set to zero.
| |
| Jagger Software Ltd | |
| Company # 4070126 | |
| VAT # 762 5213 42 |