Warning

You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.

RSHIFT()

Since version 2.1

Syntax:

rshift!(<byte expression> [, <byte positions>])

or

rshift(<int expression> [, <byte positions>])

The RSHIFT() function shifts each bit in expression to the right by the number of positions and returns the result of the operation.

The second argument can be omitted and it defaults to 1.

Warning: passing positions bigger than 127 will lead to undefined results.

Performance tip

Shifting the bits to the left is equivalent to dividing by powers of two, however much faster. Example:

rem -- this is slow
x = 364
y = x / 4

rem -- this is fast
x = 364
y = rshift(x, 2)