Home > Language Reference > Operators

Shr Operator

Bitwise shift right of an integer value.

Syntax

Result = Expr1 Shr Expr2

ParameterDescription
ResultResult of the bitwise shift.
Expr1Integer value to be shifted right.
Expr2Number of bits to shift.

Remarks

This operator can only apply to operands of integer types, ie Byte, Integer or Long. When applied to any other type, a compile time error occurs. The operation is always carried out using the type of Expr1. The result is then converted, if necessary, into the same type as Result. The value of Expr2 is considered as unsigned, modulo 64.

If applied to the unsigned type Byte, the most significant bits are filled with zeros when shifting. On the other hand, if applied to signed types Integer or Long, the most significant bit is propagated, preserving the sign of the initial value.

Note that this operation cannot overflow.

Shifting right an integer value by n bits is not the same as dividing by 2^n. Integer division rounds towards zero, while bitwise shift right rounds down. Thus, the two operations behave differently for negative numbers.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0-
Windows CEWindows CE 3.0-