Operators: >>

Right shift operator.

Syntax

integer‑operand>>integer‑operand

Bitwise right shift

The operator >> shifts the left integer operand bitwise to the right, where the number of bits to shift is determined by the right operand. All bits shifted off to the right are discarded. If the left operand is an unsigned integer, then the resulting value is zero filled from the left. In turn, if the left operand is a signed integer, the resulting value is filled with copies of the leftmost bit (of the sign bit). The operation results in the data type corresponding to the left operand. For example:

var uint32 a = 0x00AA5500; var int32 b = -11162880; var int32 c = 4; var int32 d = 0; var int32 e = -1; var uint32 result = a >> c; // result = 0x000AA550 var uint32 result = a >> d; // result = 0x00AA5500 var uint32 result = a >> e; // result = 0x00000000 var int32 result = b >> c; // result = -697680 var int32 result = b >> d; // result = -11162880 var int32 result = b >> e; // result = -1