Long integer shift right
Bytecode
Type | Description |
u1 | lshr opcode = 0x7B (123) |
Stack ..., value1.word1, value1.word2, value2 => ..., result.word1, result.word2
Description
Pops an int and a long integer from the stack. Shifts value2 (the long integer)
right by the amount indicated in the low six bits of value1 (an int). The long
integer result is then pushed back onto the stack. The value is shifted
arithmetically (preserving the sign extension).
This is the same as computing the expression: x / 2s
where s is value1 and x is value2.
k.
; This is like the Java code: ; long x; ; x >>= 3; ; lload_1 ; load long in local variable 1 onto stack iconst_3 ; push the integer 3 onto the stack lshr ; arithmetic shift right lstore_1 ; store the long result in local variable 1
Notes
The resulting value is , where
s is value2 & 0x3f. For nonnegative value1, this is equivalent to
truncating
long
division by 2 to the power s
. The shift distance
actually used is therefore always in the range 0 to 63, inclusive, as if value2
were subjected to a bitwise logical AND with the mask value 0x3f.