Rol Function

Purpose

Rotates a bit pattern left.

Syntax

Functions:Rol(m,n)

Rol|(m,n)

Rol&(m,n)

Rol%(m,n)

Rol8(m, n)

Operators:m Rol n

m Rol8 n

Assignment:Rol ivar, n

m, n:integer expression
ivar:integer variable

Description

Rol and Rol% shifts the bit pattern of a 32-bit integer expressions m, n places left (Rol = ROtate Left) and "wraps around" the bits moved off the left end to the right end again. The resulting new value is, optionally, stored in a variable. Rol&(m, n) and Rol|(m, n) rotate the bit pattern of a 16-bit or an 8-bit integer expression m respectively, n places left. Ror8 rotates a Large integer.

Rol and Rol8 can be used as operators as well.

Rol ivar, n rotates the value in ivar n places and stores the value back in ivar.

Example

Debug.Show

Local a%, l%, v As Large

Local Int x, y

Trace Bin$(202, 16)

// prints 0000000011001010

Trace Bin$(202 Rol 4, 16)

// prints 0000110010100000

l% = 202 Rol 4

Trace l%

// prints 0000110010100000

Trace Bin(l%, 16)

x = 202, y = 4

Rol x, 4

Trace Bin(x, 16)

// prints 0000110010100000

v = Large 20222022222 Rol8 64

Trace v

// prints 20222022222

See Also

Sar, Shl, Shr, Ror

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