Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


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

d2f

Operation

Convert double to float

Format

d2f

Forms

d2f = 144 (0x90)

Operand Stack

..., value ..., result

Description

The value on 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 in value'. Then value' is converted to a float result using IEEE 754 round to nearest mode. The result is pushed onto the operand stack.

Where an d2f instruction 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 an d2f instruction 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 finite value' too small to be represented as a float is converted to a zero of the same sign; a finite value' 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

The d2f instruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude of value' and may also lose precision.


d2i

Operation

Convert double to int

Format

d2i

Forms

d2i = 142 (0x8e)

Operand Stack

..., value ..., result

Description

The value on 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 in value'. Then value' is converted to an int. The result is pushed onto the operand stack:

Notes

The d2i instruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude of value' and may also lose precision.


d2l

Operation

Convert double to long

Format

d2l

Forms

d2l = 143 (0x8f)

Operand Stack

..., value ..., result

Description

The value on 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 in value'. Then value' is converted to a long. The result is pushed onto the operand stack:

Notes

The d2l instruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude of value' and may also lose precision.


dadd

Operation

Add double

Format

dadd

Forms

dadd = 99 (0x63)

Operand Stack

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

Description

Both value1 and value2 must be of type double. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting in value1' and value2'. The double result is value1' + value2'. The result is pushed onto the operand stack.

The result of a dadd instruction is governed by the rules of IEEE arithmetic:

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 a dadd instruction never throws a runtime exception.


daload

Operation

Load double from array

Format

daload

Forms

daload = 49 (0x31)

Operand Stack

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

Description

The arrayref must be of type reference and must refer to an array whose components are of type double. The index must be of type int. Both arrayref and index are popped from the operand stack. The double value in the component of the array at index is retrieved and pushed onto the operand stack.

Runtime Exceptions

If arrayref is null, daload throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the daload instruction throws an ArrayIndexOutOfBoundsException.


dastore

Operation

Store into double array

Format

dastore

Forms

dastore = 82 (0x52)

Operand Stack

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

Description

The arrayref must be of type reference and must refer to an array whose components are of type double. The index must be of type int, and value must be of type double. The arrayref, index, and value are popped from the operand stack. The double value undergoes value set conversion (§3.8.3), resulting in value', which is stored as the component of the array indexed by index.

Runtime Exceptions

If arrayref is null, dastore throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the dastore instruction throws an ArrayIndexOutOfBoundsException.


dcmp<op>

Operation

Compare double

Format

dcmp<op>

Forms

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

Operand Stack

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

Description

Both value1 and value2 must be of type double. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting in value1' and value2'. A floating-point comparison is performed:

· Otherwise, at least one of value1' or value2' is NaN. The dcmpg instruction pushes the int value 1 onto the operand stack and the dcmpl instruction pushes the int value -1 onto the operand stack.

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

The dcmpg and dcmpl instructions 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 both dcmpg and dcmpl available, any double comparison may be compiled to push the same result onto 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."


dconst_<d>

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.0 or 1.0) onto the operand stack.


ddiv

Operation

Divide double

Format

ddiv

Forms

ddiv = 111 (0x6f)

Operand Stack

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

Description

Both value1 and value2 must be of type double. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting in value1' and value2'. The double result is value1' / value2'. The result is pushed onto the operand stack.

The result of a ddiv instruction is governed by the rules of IEEE arithmetic:

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 a ddiv instruction never throws a runtime exception.


dload

Operation

Load double from local variable

Format

dload
index

Forms

dload = 24 (0x18)

Operand Stack

... ..., value

Description

The index is an unsigned byte. Both index and index + 1 must be indices into the local variable array of the current frame (§3.6). The local variable at index must contain a double. The value of the local variable at index is pushed onto the operand stack.

Notes

The dload opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index.


dload_<n>

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> + 1 must be indices into the local variable array of the current frame (§3.6). The local variable at <n> must contain a double. The value of the local variable at <n> is pushed onto the operand stack.

Notes

Each of the dload_<n> instructions is the same as dload with an index of <n>, except that the operand <n> is implicit.


dmul

Operation

Multiply double

Format

dmul

Forms

dmul = 107 (0x6b)

Operand Stack

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

Description

Both value1 and value2 must be of type double. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting in value1' and value2'. The double result is value1' * value2'. The result is pushed onto the operand stack.

The result of a dmul instruction is governed by the rules of IEEE arithmetic:

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 a dmul instruction never throws a runtime exception.


dneg

Operation

Negate double

Format

dneg

Forms

dneg = 119 (0x77)

Operand Stack

..., value ..., result

Description

The value must be of type double. It is popped from the operand stack and undergoes value set conversion (§3.8.3), resulting in value'. The double result is the arithmetic negation of value'. The result is 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:


drem

Operation

Remainder double

Format

drem

Forms

drem = 115 (0x73)

Operand Stack

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

Description

Both value1 and value2 must be of type double. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting in value1' and value2'. The result is calculated and pushed onto the operand stack as a double.

The result of a drem instruction 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 is not analogous to that of the usual integer remainder operator. Instead, the Java virtual machine defines drem to behave in a manner analogous to that of the Java virtual machine integer remainder instructions (irem and lrem); this may be compared with the C library function fmod.

The result of a drem instruction is governed by these rules:

Despite the fact that division by zero may occur, evaluation of a drem instruction 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.


dreturn

Operation

Return double from method

Format

dreturn

Forms

dreturn = 175 (0xaf)

Operand Stack

..., value [empty]

Description

The current method must have return type double. The value must 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 a monitorexit instruction. If no exception is thrown, value is popped from the operand stack of the current frame (§3.6) and undergoes value set conversion (§3.8.3), resulting in value'. The value' 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, dreturn throws an IllegalMonitorStateException. This can happen, for example, if a synchronized method contains a monitorexit instruction, but no monitorenter instruction, 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, then dreturn throws an IllegalMonitorStateException.


dstore

Operation

Store double into local variable

Format

dstore
index

Forms

dstore = 57 (0x39)

Operand Stack

..., value ...

Description

The index is an unsigned byte. Both index and index + 1 must be indices into the local variable array of the current frame (§3.6). The value on 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 in value'. The local variables at index and index + 1 are set to value'.

Notes

The dstore opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index.


dstore_<n>

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> + 1 must be indices into the local variable array of the current frame (§3.6). The value on 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 in value'. The local variables at <n> and <n> + 1 are set to value'.

Notes

Each of the dstore_<n> instructions is the same as dstore with an index of <n>, except that the operand <n> is implicit.


dsub

Operation

Subtract double

Format

dsub

Forms

dsub = 103 (0x67)

Operand Stack

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

Description

Both value1 and value2 must be of type double. The values are popped from the operand stack and undergo value set conversion (§3.8.3), resulting in value1' and value2'. The double result is value1' - value2'. The result is 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 the dsub instruction, 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 a dsub instruction never throws a runtime exception.


dup

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.

The dup instruction must not be used unless value is a value of a category 1 computational type (§3.11.1).


dup_x1

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.

The dup_x1 instruction must not be used unless both value1 and value2 are values of a category 1 computational type (§3.11.1).


dup_x2

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

where value1, value2, and value3 are all values of a category 1 computational type (§3.11.1).

Form 2:

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

where value1 is a value of a category 1 computational type and value2 is 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.


dup2

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 both value1 and value2 are values of a category 1 computational type (§3.11.1).

Form 2:

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

where value is 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.


dup2_x1

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

where value1, value2, and value3 are all values of a category 1 computational type (§3.11.1).

Form 2:

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

where value1 is a value of a category 2 computational type and value2 is 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.


dup2_x2

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

where value1, value2, value3, and value4 are all values of a category 1 computational type (§3.11.1).

Form 2:

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

where value1 is a value of a category 2 computational type and value2 and value3 are both values of a category 1 computational type (§3.11.1).

Form 3:

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

where value1 and value2 are both values of a category 1 computational type and value3 is a value of a category 2 computational type (§3.11.1).

Form 4:

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

where value1 and value2 are 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 JavaTM Virtual Machine Specification
Copyright © 1999 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to jvm@java.sun.com