Flylib.com

Books Software

 
 
 

Java Virtual Machine (Java Series) - page 51

prev next contents
bipush
push one-byte signed integer
Jasmin Syntax

bipush <n>

<n> is an integer >= -128 and <= 127 that is pushed onto the stack.

Stack

B efore

After
...
<n>
...
...
Description

bipush takes a single parameter, <n> (an 8-bit signed integer), sign extends it to a 32-bit int, and pushes the resulting int value onto the operand stack.

bipush is typically more efficient than ldc . It also occupies fewer bytes in the class file.

Example


bipush    0x10    ; push the value 0x10 (16) onto the operand stack

Bytecode

The bipush opcode is followed in the bytecode by an 8-bit signed byte specifying the integer value to push.

Type

Description
u1
bipush opcode = 0x10 (16)
s1
<n>
See Also

sipush , ldc , ldc_w , ldc2_w , aconst_null , iconst_m1 , iconst_<n> , lconst_<l> , fconst_<f> , dconst_<d>


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates
prev next contents
d2f
convert double to float
Jasmin Syntax

d2f

Stack

B efore

After
double-word1
float-result
double-word2
...
...

Description

Pops a two-word double precision floating point number off of the operand stack, casts it into a single precision float, and pushes the resulting float back onto the stack. There is a loss of precision and range in the result.

This conversion is done in accordance with IEEE 754 specifications, with rounding using IEEE 754 round-to- nearest mode.

The sign of the value if preserved. A value which is too small to be represented as a float is converted to positive or negative zero. A value that is too large to be represented as a float is converted to positive infinity or negative infinity. If the value was NaN, the result is NaN.

Bytecode

Type

Description
u1
d2f opcode = 0x90 (144)
See Also

d2i , d2l


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates
prev next contents
d2i
convert double to integer
Jasmin Syntax

d2i

Stack

B efore

After
double-word1
integer-result
double-word2
...
...

Description

Pops a two-word double precision floating point number off of the operand stack, casts it into a 32-bit int, and pushes the resulting int onto the stack.

Rounding is done using IEEE 754 round-to- nearest mode. The fractional part is lost by rounding towards zero, so (int)-3.14 becomes -3.

If the original double value is NaN, the result is 0. If the value is too large to be represented as an integer, or if it is positive infinity, the result is the largest possible integer 0x7FFFFFFF. If the value is too small (i.e. a negative value of large magnitude, or negative infinity) then the result is the most negative integer 0x80000000.

Bytecode

Type

Description
u1
d2i opcode = 0x8E (142)
See Also

d2l , d2f


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates
prev next contents
d2l
convert double to long integer
Jasmin Syntax

d2l

Stack

B efore

After
double-word1
long-word1
double-word2
long-word2
...
...
Description

Pops a two-word double precision floating point number off of the operand stack, converts it into a 64-bit long integer, and pushes the resulting two-word long onto the stack.

Rounding is done using IEEE 754 round-to- nearest mode. The fractional part is lost by rounding towards zero, so (long)-3.14 becomes -3.

If the original double value is NaN, the result is 0. If the value is too large to be represented as an integer, or if it is positive infinity, the result is the largest possible long integer Long.MAX_VALUE. If the value is too small (i.e. a negative value of large magnitude, or negative infinity) then the result is the most negative long integer Long.MIN_VALUE.

In some implementations , this may be coded using the C casting mechanism, e.g.


void d2l(double d, int &l_high, int &l_low)
{
    l_low = (unsigned int)d;
	l_high = (unsigned int)(d / 2**32);
}

where l_low and l_high are respectively the least significant and most significant 32-bit words of the long.

Bytecode

Type

Description
u1
d2l opcode = 0x8F (143)
See Also

d2i , d2f


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