Contents | Prev | Next | Index | The Java^{TM} Virtual Machine Specification |

A B C D F G I J L M N P R S T W

**Operation**

Convert`double`

to`float`

Format

d2f

**Forms**

d2f= 144 (0x90)

**Operand Stack**

...,value...,result

**Description**

Thevalueon the top of the operand stack must be of type`double`

. It is popped from the operand stack and undergoes value set conversion (§3.8.3) resulting invalue'. Thenvalue'is converted to a`float`

resultusing IEEE 754 round to nearest mode. Theresultis pushed onto the operand stack.

Where and2finstruction is FP-strict (§3.8.2), the result of the conversion is always rounded to the nearest representable value in the float value set (§3.3.2).

Where and2finstruction is not FP-strict, the result of the conversion may be taken from the float-extended-exponent value set (§3.3.2); it is not necessarily rounded to the nearest representable value in the float value set.

A finitevalue'too small to be represented as a`float`

is converted to a zero of the same sign; a finitevalue'too large to be represented as a`float`

is converted to an infinity of the same sign. A`double`

NaN is converted to a`float`

NaN.

**Notes**

Thed2finstruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude ofvalue'and may also lose precision.

**Operation**

Convert`double`

to`int`

Format

d2i

**Forms**

d2i= 142 (0x8e)

**Operand Stack**

...,value...,result

**Description**

Thevalueon the top of the operand stack must be of type`double`

. It is popped from the operand stack and undergoes value set conversion (§3.8.3) resulting invalue'. Thenvalue'is converted to an`int`

. Theresultis pushed onto the operand stack:

- If the
*value'*is NaN, the*result*of the conversion is an`int`

0. - Otherwise, if the
*value'*is not an infinity, it is rounded to an integer value*V*, rounding towards zero using IEEE 754 round towards zero mode. If this integer value*V*can be represented as an`int`

, then the*result*is the`int`

value*V*. - Otherwise, either the
*value'*must be too small (a negative value of large magnitude or negative infinity), and the*result*is the smallest representable value of type`int`

, or the*value'*must be too large (a positive value of large magnitude or positive infinity), and the*result*is the largest representable value of type`int`

.

**Notes**

Thed2iinstruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude ofvalue'and may also lose precision.

**Operation**

Convert`double`

to`long`

Format

d2l

**Forms**

d2l= 143 (0x8f)

**Operand Stack**

...,value...,result

**Description**

Thevalueon the top of the operand stack must be of type`double`

. It is popped from the operand stack and undergoes value set conversion (§3.8.3) resulting invalue'. Thenvalue'is converted to a`long`

. Theresultis pushed onto the operand stack:

- If the
*value'*is NaN, the*result*of the conversion is a`long`

0. - Otherwise, if the
*value'*is not an infinity, it is rounded to an integer value*V*, rounding towards zero using IEEE 754 round towards zero mode. If this integer value*V*can be represented as a`long`

, then the*result*is the`long`

value*V*. - Otherwise, either the
*value'*must be too small (a negative value of large magnitude or negative infinity), and the*result*is the smallest representable value of type`long`

, or the*value'*must be too large (a positive value of large magnitude or positive infinity), and the*result*is the largest representable value of type`long`

.

**Notes**

Thed2linstruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude ofvalue'and may also lose precision.

**Operation**

Add`double`

Format

dadd

**Forms**

dadd= 99 (0x63)

**Operand Stack**

...,value1,value2...,result

**Description**

Bothvalue1andvalue2must be of type`double`

. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting invalue1'andvalue2'. The`double`

resultisvalue1'+value2'. Theresultis pushed onto the operand stack.

The result of adaddinstruction is governed by the rules of IEEE arithmetic:

- If either
*value1'*or*value2'*is NaN, the result is NaN. - The sum of two infinities of opposite sign is NaN.
- The sum of two infinities of the same sign is the infinity of that sign.
- The sum of an infinity and any finite value is equal to the infinity.
- The sum of two zeroes of opposite sign is positive zero.
- The sum of two zeroes of the same sign is the zero of that sign.
- The sum of a zero and a nonzero finite value is equal to the nonzero value.
- The sum of two nonzero finite values of the same magnitude and opposite sign is positive zero.
- In the remaining cases, where neither operand is an infinity, a zero, or NaN and the values have the same sign or have different magnitudes, the sum is computed and rounded to the nearest representable value using IEEE 754 round to nearest mode. If the magnitude is too large to represent as a
`double`

, we say the operation overflows; the result is then an infinity of appropriate sign. If the magnitude is too small to represent as a`double`

, we say the operation underflows; the result is then a zero of appropriate sign.

The Java virtual machine requires support of gradual underflow as defined by IEEE 754. Despite the fact that overflow, underflow, or loss of precision may occur, execution of adaddinstruction never throws a runtime exception.

**Operation**

Load`double`

from array

Format

daload

**Forms**

daload= 49 (0x31)

**Operand Stack**

...,arrayref,index...,value

**Description**

Thearrayrefmust be of type`reference`

and must refer to an array whose components are of type`double`

. Theindexmust be of type`int`

. Botharrayrefandindexare popped from the operand stack. The`double`

valuein the component of the array atindexis retrieved and pushed onto the operand stack.

**Runtime Exceptions**

Ifarrayrefis`null`

,daloadthrows a`NullPointerException`

.

Otherwise, ifindexis not within the bounds of the array referenced byarrayref, thedaloadinstruction throws an`ArrayIndexOutOfBoundsException`

.

**Operation**

Store into`double`

array

Format

dastore

**Forms**

dastore= 82 (0x52)

**Operand Stack**

...,arrayref,index,value...

**Description**

Thearrayrefmust be of type`reference`

and must refer to an array whose components are of type`double`

. Theindexmust be of type`int`

, andvaluemust be of type`double`

. Thearrayref,index, andvalueare popped from the operand stack. The`double`

valueundergoes value set conversion (§3.8.3), resulting invalue', which is stored as the component of the array indexed byindex.

**Runtime Exceptions**

Ifarrayrefis`null`

,dastorethrows a`NullPointerException`

.

Otherwise, ifindexis not within the bounds of the array referenced byarrayref, thedastoreinstruction throws an`ArrayIndexOutOfBounds`

`Exception`

.

**Operation**

Compare`double`

Format

dcmp<op>

**Forms**

dcmpg= 152 (0x98)dcmpl= 151 (0x97)

**Operand Stack**

...,value1,value2...,result

**Description**

Bothvalue1andvalue2must be of type`double`

. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting invalue1'andvalue2'. A floating-point comparison is performed:

- If
*value1'*is greater than*value2'*, the`int`

value*1*is pushed onto the operand stack. - Otherwise, if
*value1'*is equal to*value2'*, the`int`

value*0*is pushed onto the operand stack. - Otherwise, if
*value1'*is less than*value2'*, the`int`

value -*1*is pushed onto the operand stack.

`int`

value `int`

value -

Floating-point comparison is performed in accordance with IEEE 754. All values other than NaN are ordered, with negative infinity less than all finite values and positive infinity greater than all finite values. Positive zero and negative zero are considered equal.

**Notes**

Thedcmpganddcmplinstructions differ only in their treatment of a comparison involving NaN. NaN is unordered, so any`double`

comparison fails if either or both of its operands are NaN. With bothdcmpganddcmplavailable, any`double`

comparison may be compiled to push the sameresultonto the operand stack whether the comparison fails on non-NaN values or fails because it encountered a NaN. For more information, see Section 7.5, "More Control Examples."

**Operation**

Push`double`

Format

dconst_<d>

**Forms**

dconst_0= 14 (0xe)dconst_1= 15 (0xf)

**Operand Stack**

... ...,<d>

**Description**

Push the`double`

constant<d>(0.0or1.0) onto the operand stack.

**Operation**

Divide`double`

Format

ddiv

**Forms**

ddiv= 111 (0x6f)

**Operand Stack**

...,value1,value2...,result

**Description**

Bothvalue1andvalue2must be of type`double`

. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting invalue1'andvalue2'. The`double`

resultisvalue1'/value2'. Theresultis pushed onto the operand stack.

The result of addivinstruction is governed by the rules of IEEE arithmetic:

- If either
*value1'*or*value2'*is NaN, the result is NaN. - If neither
*value1'*nor*value2'*is NaN, the sign of the result is positive if both values have the same sign, negative if the values have different signs. - Division of an infinity by an infinity results in NaN.
- Division of an infinity by a finite value results in a signed infinity, with the sign-producing rule just given.
- Division of a finite value by an infinity results in a signed zero, with the sign-producing rule just given.
- Division of a zero by a zero results in NaN; division of zero by any other finite value results in a signed zero, with the sign-producing rule just given.
- Division of a nonzero finite value by a zero results in a signed infinity, with the sign-producing rule just given.
- In the remaining cases, where neither operand is an infinity, a zero, or NaN, the quotient is computed and rounded to the nearest
`double`

using IEEE 754 round to nearest mode. If the magnitude is too large to represent as a`double`

, we say the operation overflows; the result is then an infinity of appropriate sign. If the magnitude is too small to represent as a`double`

, we say the operation underflows; the result is then a zero of appropriate sign.

The Java virtual machine requires support of gradual underflow as defined by IEEE 754. Despite the fact that overflow, underflow, division by zero, or loss of precision may occur, execution of addivinstruction never throws a runtime exception.

**Operation**

Load`double`

from local variable

Format

dloadindex

**Forms**

dload= 24 (0x18)

**Operand Stack**

... ...,value

**Description**

Theindexis an unsigned byte. Bothindexandindex+1must be indices into the local variable array of the current frame (§3.6). The local variable atindexmust contain a`double`

. Thevalueof the local variable atindexis pushed onto the operand stack.

**Notes**

Thedloadopcode can be used in conjunction with thewideinstruction to access a local variable using a two-byte unsigned index.

**Operation**

Load`double`

from local variable

Format

dload_<n>

**Forms**

dload_0= 38 (0x26)dload_1= 39 (0x27)dload_2= 40 (0x28)dload_3= 41 (0x29)

**Operand Stack**

... ...,value

**Description**

Both<n>and<n>+1must be indices into the local variable array of the current frame (§3.6). The local variable at<n>must contain a`double`

. Thevalueof the local variable at<n>is pushed onto the operand stack.

**Notes**

Each of thedload_<n>instructions is the same asdloadwith anindexof<n>, except that the operand<n>is implicit.

**Operation**

Multiply`double`

Format

dmul

**Forms**

dmul= 107 (0x6b)

**Operand Stack**

...,value1,value2...,result

**Description**

Bothvalue1andvalue2must be of type`double`

. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting invalue1'andvalue2'. The`double`

resultisvalue1'*value2'. Theresultis pushed onto the operand stack.

The result of admulinstruction is governed by the rules of IEEE arithmetic:

- If either
*value1'*or*value2'*is NaN, the result is NaN. - If neither
*value1'*nor*value2'*is NaN, the sign of the result is positive if both values have the same sign and negative if the values have different signs. - Multiplication of an infinity by a zero results in NaN.
- Multiplication of an infinity by a finite value results in a signed infinity, with the sign-producing rule just given.
- In the remaining cases, where neither an infinity nor NaN is involved, the product is computed and rounded to the nearest representable value using IEEE 754 round to nearest mode. If the magnitude is too large to represent as a
`double`

, we say the operation overflows; the result is then an infinity of appropriate sign. If the magnitude is too small to represent as a`double`

, we say the operation underflows; the result is then a zero of appropriate sign.

The Java virtual machine requires support of gradual underflow as defined by IEEE 754. Despite the fact that overflow, underflow, or loss of precision may occur, execution of admulinstruction never throws a runtime exception.

**Operation**

Negate`double`

Format

dneg

**Forms**

dneg= 119 (0x77)

**Operand Stack**

...,value...,result

**Description**

Thevaluemust be of type`double`

. It is popped from the operand stack and undergoes value set conversion (§3.8.3), resulting invalue'. The`double`

resultis the arithmetic negation ofvalue'. Theresultis pushed onto the operand stack.

For`double`

values, negation is not the same as subtraction from zero. If`x`

is +`0.0`

, then`0.0`

-`x`

equals +`0.0`

, but -`x`

equals -`0.0`

. Unary minus merely inverts the sign of a`double`

.

Special cases of interest:

- If the operand is NaN, the result is NaN (recall that NaN has no sign).
- If the operand is an infinity, the result is the infinity of opposite sign.
- If the operand is a zero, the result is the zero of opposite sign.

**Operation**

Remainder`double`

Format

drem

**Forms**

drem= 115 (0x73)

**Operand Stack**

...,value1,value2...,result

**Description**

Bothvalue1andvalue2must be of type`double`

. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting invalue1'andvalue2'. Theresultis calculated and pushed onto the operand stack as a`double`

.

The result of adreminstruction is not the same as that of the so-called remainder operation defined by IEEE 754. The IEEE 754 "remainder" operation computes the remainder from a rounding division, not a truncating division, and so its behavior isnotanalogous to that of the usual integer remainder operator. Instead, the Java virtual machine definesdremto behave in a manner analogous to that of the Java virtual machine integer remainder instructions (iremandlrem); this may be compared with the C library function`fmod`

.

The result of adreminstruction is governed by these rules:

- If either
*value1'*or*value2'*is NaN, the result is NaN. - If neither
*value1'*nor*value2'*is NaN, the sign of the result equals the sign of the dividend. - If the dividend is an infinity or the divisor is a zero or both, the result is NaN.
- If the dividend is finite and the divisor is an infinity, the result equals the dividend.
- If the dividend is a zero and the divisor is finite, the result equals the dividend.
- In the remaining cases, where neither operand is an infinity, a zero, or NaN, the floating-point remainder
*result*from a dividend*value1'*and a divisor*value2'*is defined by the mathematical relation*result*=*value1'*-*value2'***q*), where*q*is an integer that is negative only if*value1'*/*value2'*is negative, and positive only if*value1'*/*value2'*is positive, and whose magnitude is as large as possible without exceeding the magnitude of the true mathematical quotient of*value1'*and*value2'*.

Despite the fact that division by zero may occur, evaluation of adreminstruction never throws a runtime exception. Overflow, underflow, or loss of precision cannot occur.

**Notes**

```
The IEEE 754 remainder operation may be computed by the library routine
````Math.IEEEremainder`

.

**Operation**

Return`double`

from method

Format

dreturn

**Forms**

dreturn= 175 (0xaf)

**Operand Stack**

...,value[empty]

**Description**

The current method must have return type`double`

. Thevaluemust be of type`double`

. If the current method is a`synchronized`

method, the monitor acquired or reentered on invocation of the method is released or exited (respectively) as if by execution of amonitorexitinstruction. If no exception is thrown,valueis popped from the operand stack of the current frame (§3.6) and undergoes value set conversion (§3.8.3), resulting invalue'. Thevalue'is pushed onto the operand stack of the frame of the invoker. Any other values on the operand stack of the current method are discarded.

The interpreter then returns control to the invoker of the method, reinstating the frame of the invoker.

**Runtime Exceptions**

If the current method is a`synchronized`

method and the current thread is not the owner of the monitor acquired or reentered on invocation of the method,dreturnthrows an`IllegalMonitorStateException`

. This can happen, for example, if a`synchronized`

method contains amonitorexitinstruction, but nomonitorenterinstruction, on the object on which the method is synchronized.

Otherwise, if the virtual machine implementation enforces the rules on structured use of locks described in §8.13 and if the first of those rules is violated during invocation of the current method, thendreturnthrows an`IllegalMonitorStateException`

.

**Operation**

Store`double`

into local variable

Format

dstoreindex

**Forms**

dstore= 57 (0x39)

**Operand Stack**

...,value...

**Description**

Theindexis an unsigned byte. Bothindexandindex+1must be indices into the local variable array of the current frame (§3.6). Thevalueon the top of the operand stack must be of type`double`

. It is popped from the operand stack and undergoes value set conversion (§3.8.3), resulting invalue'. The local variables atindexandindex+1are set tovalue'.

**Notes**

Thedstoreopcode can be used in conjunction with thewideinstruction to access a local variable using a two-byte unsigned index.

**Operation**

Store`double`

into local variable

Format

dstore_<n>

**Forms**

dstore_0= 71 (0x47)dstore_1= 72 (0x48)dstore_2= 73 (0x49)dstore_3= 74 (0x4a)

**Operand Stack**

...,value...

**Description**

Both<n>and<n> + 1must be indices into the local variable array of the current frame (§3.6). Thevalueon the top of the operand stack must be of type`double`

. It is popped from the operand stack and undergoes value set conversion (§3.8.3), resulting invalue'. The local variables at<n>and<n>+1are set tovalue'.

**Notes**

Each of thedstore_<n>instructions is the same asdstorewith anindexof<n>, except that the operand<n>is implicit.

**Operation**

Subtract`double`

Format

dsub

**Forms**

dsub= 103 (0x67)

**Operand Stack**

...,value1,value2...,result

**Description**

Bothvalue1andvalue2must be of type`double`

. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting invalue1'andvalue2'. The`double`

resultisvalue1'-value2'. Theresultis pushed onto the operand stack.

For`double`

subtraction, it is always the case that`a`

-`b`

produces the same result as`a`

+(-`b`

). However, for thedsubinstruction, subtraction from zero is not the same as negation, because if`x`

is +`0.0`

, then`0.0`

-`x`

equals +`0.0`

, but -`x`

equals -`0.0`

.

The Java virtual machine requires support of gradual underflow as defined by IEEE 754. Despite the fact that overflow, underflow, or loss of precision may occur, execution of adsubinstruction never throws a runtime exception.

**Operation**

Duplicate the top operand stack value

Format

dup

**Forms**

dup= 89 (0x59)

**Operand Stack**

...,value...,value,value

**Description**

Duplicate the top value on the operand stack and push the duplicated value onto the operand stack.

Thedupinstruction must not be used unlessvalueis a value of a category 1 computational type (§3.11.1).

**Operation**

Duplicate the top operand stack value and insert two values down

Format

dup_x1

**Forms**

dup_x1= 90 (0x5a)

**Operand Stack**

...,value2,value1...,value1,value2,value1

**Description**

Duplicate the top value on the operand stack and insert the duplicated value two values down in the operand stack.

Thedup_x1instruction must not be used unless bothvalue1andvalue2are values of a category 1 computational type (§3.11.1).

**Operation**

Duplicate the top operand stack value and insert two or three values down

Format

dup_x2

**Forms**

dup_x2= 91 (0x5b)

**Operand Stack**

Form 1:

...,value3,value2,value1...,value1,value3,value2,value1

wherevalue1,value2, andvalue3are all values of a category 1 computational type (§3.11.1).

Form 2:

...,value2,value1...,value1,value2,value1

wherevalue1is a value of a category 1 computational type andvalue2is a value of a category 2 computational type (§3.11.1).

**Description**

Duplicate the top value on the operand stack and insert the duplicated value two or three values down in the operand stack.

**Operation**

Duplicate the top one or two operand stack values

Format

dup2

**Forms**

dup2= 92 (0x5c)

**Operand Stack**

Form 1:

...,value2,value1...,value2,value1,value2,value1

where bothvalue1andvalue2are values of a category 1 computational type (§3.11.1).

Form 2:

...,value...,value,value

wherevalueis a value of a category 2 computational type (§3.11.1).

**Description**

Duplicate the top one or two values on the operand stack and push the duplicated value or values back onto the operand stack in the original order.

**Operation**

Duplicate the top one or two operand stack values and insert two or three values down

Format

dup2_x1

**Forms**

dup2_x1= 93 (0x5d)

**Operand Stack**

Form 1:

...,value3,value2,value1...,value2,value1,value3,value2,value1

wherevalue1,value2, andvalue3are all values of a category 1 computational type (§3.11.1).

Form 2:

...,value2,value1...,value1,value2,value1

wherevalue1is a value of a category 2 computational type andvalue2is a value of a category 1 computational type (§3.11.1).

**Description**

Duplicate the top one or two values on the operand stack and insert the duplicated values, in the original order, one value beneath the original value or values in the operand stack.

**Operation**

Duplicate the top one or two operand stack values and insert two, three, or four values down

Format

dup2_x2

**Forms**

dup2_x2= 94 (0x5e)

**Operand Stack**

Form 1:

...,value4,value3,value2,value1...,value2,value1,value4,value3,value2,value1

wherevalue1,value2,value3, andvalue4are all values of a category 1 computational type (§3.11.1).

Form 2:

...,value3,value2,value1...,value1,value3,value2,value1

wherevalue1is a value of a category 2 computational type andvalue2andvalue3are both values of a category 1 computational type (§3.11.1).

Form 3:

...,value3,value2,value1...,value2,value1,value3,value2,value1

wherevalue1andvalue2are both values of a category 1 computational type andvalue3is a value of a category 2 computational type (§3.11.1).

Form 4:

...,value2,value1...,value1,value2,value1

wherevalue1andvalue2are both values of a category 2 computational type (§3.11.1).

**Description**

Duplicate the top one or two values on the operand stack and insert the duplicated values, in the original order, into the operand stack.

Contents | Prev | Next | Index

*The Java*^{TM}* Virtual Machine Specification *

*Copyright © 1999 Sun Microsystems, Inc.
All rights reserved*

Please send any comments or corrections to jvm@java.sun.com