86.

prev next contents
i2s

convert integer to short integer

Jasmin Syntax
     i2s 
Stack

Before

After
value
result
...
...
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.

Bytecode

Type

Description
u1
i2s opcode = 0x93 (147)
See Also

i2b, i2c


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates


Java Virtual Machine
Java Virtual Machine (Java Series)
ISBN: 1565921941
EAN: 2147483647
Year: 1996
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net