i2b :
convert integer to byte : index : visitInsn()
- Description
- Converts an integer to a signed byte. A 32-bit int is popped off the
stack, the top 24 bits are discarded (they are set to zero), then the resulting
value is signed extended to an int. The int result is pushed back onto the
stack.
i2b is used in Java where there is a cast between an int and a byte. Notice
that i2b can cause a change in sign. For example, in the code:
int x = -134;
byte b = (byte)x;
The
value of b is positive 122 - the sign bit of x is lost in the conversion. - See also
- i2c i2s
- Stack
Before
|
After |
value |
result |
... |
... |
- Bytecode
Type
|
Description |
u1
|
i2b
opcode = 0x91 (145)
|