util.Integer.shiftRight
Returns the INTEGER value right-shifted by the given
bit places.
Syntax
util.Integer.shiftRight(
i INTEGER,
n SMALLINT
)
RETURNS INTEGER
- i is the integer value to shift.
- n is the right-shift distance in bits.
Usage
The util.Integer.shiftRight() method shifts the bits to the right in the integer
value passed in the first parameter by the number of places specified by the second parameter.
i : 210 (00000000 11010010)
n : 3
--------------------------------
result : 26 (00000000 00011010)
Bits shifted out from the right end are lost.
Bits shifted in from the left end are set to 0.
Note: Bitwise methods provided by the
util.Integer class are
based on the INTEGER type. Consider the following facts when using these methods: - The
INTEGERtype is a four-byte signed integer: If the bit at position 31 is set to 1, the correspondingINTEGERvalue will be negative. Thus,util.Integer.not(0)produces theINTEGERvalue-1(11111111 11111111 11111111 11111111). - The
NULLvalue for theINTEGERtype is represented internally with the value0x80000000(10000000 00000000 00000000 00000000). WhenNULLis used with theutil.Integerbitwise methods, it will be interpreted as0x80000000instead of a null value. However, if the result of the bitwise operation produces the value0x80000000, it will be interpreted asNULLwhen used in an expression.
Example
IMPORT util
MAIN
DISPLAY util.Integer.shiftRight(
util.Integer.parseBinaryString("1100"),
2 ) -- displays 3
END MAIN