i2s :
convert integer to short integer : index : visitInsn()
- Description
- Converts an integer to a signed short. A 32-bit int is popped off the
stack, the top 16 bits are set to zero, and the resulting value is then sign
extended to an int. The int result is pushed back onto the stack.
i2s is used in Java where there is an explicit case between an int and a short.
Notice that i2s can cause a change in sign. For example, in the code:
int x = -40000;
short s = (short)x;
The
value of s is positive 25536, since the sign bit of x is lost in the
conversion. - See also
- i2b i2c
- Stack
Before
|
After |
value |
result |
... |
... |
- Bytecode
Type
|
Description |
u1
|
i2s
opcode = 0x93 (147)
|