Sar Command

Purpose

Shifts a bit pattern to the right.

Syntax

Sar m, n

m:integer variable
n:iexp

Description

Sar m, n shifts a bit pattern of an integer variable m n steps to the right (Sar = Shift Right), in which the highest bit is copied (and not replaced with zero like with Shr). Each bit shift right is a division by two.

The shift operation to be performed is determined from the data type of the variable.

Example

Dim m% = 8, m8 As Large = 8

Sar m%, 2

Print m%        // = 2

Sar m8, 2

Print m8        // = 2

Remarks

See Sar() for a demonstration of how the bits are shifted.

See Also

Sar(), Shr, Shl, Ror, Rol

{Created by Sjouke Hamstra; Last updated: 22/10/2014 by James Gaite}