ShiftRight()
Summary
Does a right arithmetic shift of the bits in an integer.
Syntax
int = ShiftRight(integer int1, integer shift)
| Argument | Contents |
|---|---|
| int1 | An integer |
| shift | Number of bits to shift right, from 1 to 32; a negative value will shift left |
Returns
An integer with an arithmetic shift of the bits the specified number of places to the right.
Notes
-
Bits are dropped from the right end, and the sign bit is moved into new bits on the left.
-
The sign bit cannot change.
Examples
int = ShiftRight(15, 1) // int = 7: in binary, 1111 becomes 111
int = ShiftRight(-1, 1) // int = -1: any shift will result in -1
See Also
| Function | Summary |
|---|---|
| BitwiseAnd() | Computes the bitwise AND of two integers |
| BitwiseNot() | Computes the bitwise NOT of an integer |
| BitwiseOr() | Computes the bitwise OR of two integers |
| BitwiseXor() | Computes the bitwise exclusive OR of an integer |
| ShiftLeft() | Performs a left arithmetic shift of the bits in an integer |