Ror Function

Purpose

Rotates a bit pattern right.

Syntax

Functions:Ror(m, n)

Ror|(m, n)

Ror&(m, n)

Ror%(m, n)

Ror8(m, n)

Operators:m Ror n

m Ror8 n

Assignment:Ror, ivar, n

m, n:integer expression
ivar:integer variable

Description

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

Ror and Ror8 can be used as operators as well.

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

Example

Debug.Show

Local a%, l%, l&, l|

Trace Bin$(202, 32)

// prints 00000000000000000000000011001010

Trace Bin$(Ror(202, 4), 32)

// prints 10100000000000000000000000000100

l% = Ror(202, 4)

Trace l%

// prints -1610612724

Trace Bin$(202, 16)

// prints 0000000011001010

Trace Bin$(Ror&(202, 4), 16)

// prints 1010000000001100

l& = Ror&(202, 4)

Trace l&

// prints -24564

//

Trace Bin$(202, 8)

// prints 11001010

Trace Bin$(Ror|(202, 4), 16)

// prints 10101100

l| = Ror|(202, 4)

Trace l|// prints 172

See Also

Sar, Shl, Shr, Rol

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