Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


d2f

Operation Convert double to float

d2f


Forms d2f = 144 (0x90)

Stack ..., value.word1, value.word2 ..., result

Description The value on the top of the operand stack must be of type double. It is popped from the operand stack and converted to a float result using IEEE 754 round-to-nearest mode. The result is pushed onto the operand stack.

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

d2i


Forms d2i = 142 (0x83)

Stack ..., value.word1, value.word2 ..., result

Description The value on the top of the operand stack must be of type double. It is popped from the operand stack and converted to an int. The result is pushed onto the operand stack:

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

d2l


Forms d2l = 143 (0x8f)

Stack ..., value.word1, value.word2 ..., result.word1, result.word2

Description The value on the top of the operand stack must be of type double. It is popped from the operand stack and converted to a long. The result is pushed onto the operand stack:

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

dadd


Forms dadd = 99 (0x63)

Stack ..., value1.word1, value1.word2, value2.word1, value2.word2 ..., result.word1, result.word2

Description Both value1 and value2 must be of type double. The values are popped from the operand stack. 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

daload


Forms daload = 49 (0x31)

Stack ..., arrayref, index ..., value.word1, value.word2

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 top of 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

dastore


Forms dastore = 82 (0x52)

Stack ..., arrayref, index, value.word1, value.word2 ...

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 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, dastore throws an ArrayIndexOutOfBounds-Exception.


dcmp<op>

Operation Compare double

dcmp<op>


Forms dcmpg = 152 (0x98)

dcmpl = 151 (0x97)

Stack ..., value1.word1, value1.word2, value2.word1, value2.word1 ..., result

Description Both value1 and value2 must be of type double. The values are popped from the operand stack, and a floating-point comparison is performed. If value1 is greater than value2, the int value 1 is pushed onto the operand stack. If value1 is equal to value2, the int value 0 is pushed onto the operand stack. If value1 is less than value2, the int value -1 is pushed onto the operand stack. If either 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

dconst_<d>


Forms dconst_0 = 14 (0xe)

dconst_1 = 15 (0xf)

Stack ... ..., <d>.word1, <d>.word2

Description Push the double constant <d> (0.0 or 1.0) onto the operand stack.


ddiv

Operation Divide double

ddiv


Forms ddiv = 111 (0x6f)

Stack ..., value1.word1, value1.word2, value2.word1, value2.word2 ..., result.word1, result.word2

Description Both value1 and value2 must be of type double. The values are popped from the operand stack. 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

dload
index


Forms dload = 24 (0x18)

Stack ... ..., value.word1, value.word2

Description The index is an unsigned byte. Both index and index + 1 must be valid indices into the local variables of the current frame (§3.6). The local variables at index and index + 1 together must contain a double. The value of the local variables at index and index + 1 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

dload_<n>


Forms dload_0 = 38 (0x26)

dload_1 = 39 (0x27)

dload_2 = 40 (0x28)

dload_3 = 41 (0x29)

Stack ... ..., value.word1, value.word2

Description Both <n> and <n> + 1 must be valid indices into the local variables of the current frame (§3.6). The local variables at <n> and <n> + 1 together must contain a double. The value of the local variables at <n> and <n> + 1 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

dmul


Forms dmul = 107 (0x6b)

Stack ..., value1.word1, value1.word2, value2.word1, value2.word2 ..., result.word1, result.word2

Description Both value1 and value2 must be of type double. The values are popped from the operand stack. 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

dneg


Forms dneg = 119 (0x77)

Stack ..., value.word1, value.word2 ..., result.word1, result.word2

Description The value must be of type double. It is popped from the operand stack. The double result is the arithmetic negation of value, namely -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

drem


Forms drem = 115 (0x73)

Stack ..., value1.word1, value1.word2, value2.word1, value2.word2 ..., result.word1, result.word2

Description Both value1 and value2 must be of type double. The values are popped from the operand stack. 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:


drem

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 Java library routine Math.IEEEremainder.


dreturn

Operation Return double from method

dreturn


Forms dreturn = 175 (0xaf)

Stack ..., value.word1, value.word2

[empty]

Description The returning method must have return type double. The value must be of type double. The value is popped from the operand stack of the current frame (§3.6) and pushed onto the operand stack of the frame of the invoker. Any other values on the operand stack of the current method are discarded. If the returning 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.

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


dstore

Operation Store double into local variable

dstore
index


Forms dstore = 57 (0x39)

Stack ..., value.word1, value.word2 ...

Description The index is an unsigned byte. Both index and index + 1 must be valid indices into the 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 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

dstore_<n>


Store double into local variable

Forms dstore_0 = 71 (0x47)

dstore_1 = 72 (0x48)

dstore_2 = 73 (0x49)

dstore_3 = 74 (0x4a)

Stack ..., value.word1, value.word2 ...

Description Both <n> and <n> + 1 must be valid indices into the local variables 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 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

dsub


Forms dsub = 103 (0x67)

Stack ..., value1.word1, value1.word2, value2.word1, value2.word2 ..., result.word1, result.word2

Description Both value1 and value2 must be of type double. The values are popped from the operand stack. 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 top operand stack word

dup


Forms dup = 89 (0x59)

Stack ..., word ..., word, word

Description The top word on the operand stack is duplicated and pushed onto the operand stack.

The dup instruction must not be used unless word contains a 32-bit data type.

Notes Except for restrictions preserving the integrity of 64-bit data types, the dup instruction operates on an untyped word, ignoring the type of the datum it contains.


dup_x1

Operation Duplicate top operand stack word and put two down

dup_x1


Forms dup_x1 = 90 (0x5a)

Stack ..., word2, word1 ..., word1, word2, word1

Description The top word on the operand stack is duplicated and the copy inserted two words down in the operand stack.

The dup_x1 instruction must not be used unless each of word1 and word2 is a word that contains a 32-bit data type.

Notes Except for restrictions preserving the integrity of 64-bit data types, the dup_x1 instruction operates on untyped words, ignoring the types of the data they contain.


dup_x2

Operation Duplicate top operand stack word and put three down

dup_x2


Forms dup_x2 = 91 (0x5b)

Stack ..., word3, word2, word1 ..., word1, word3, word2, word1

Description The top word on the operand stack is duplicated and the copy inserted three words down in the operand stack.

The dup_x2 instruction must not be used unless each of word2 and word3 is a word that contains a 32-bit data type or together are the two words of a single 64-bit datum, and unless word1 contains a 32-bit data type.

Notes Except for restrictions preserving the integrity of 64-bit data types, the dup_x2 instruction operates on untyped words, ignoring the types of the data they contain.


dup2

Operation Duplicate top two operand stack word

dup2


s

Forms dup2 = 92 (0x5c)

Stack ..., word2, word1 ..., word2, word1, word2, word1

Description The top two words on the operand stack are duplicated and pushed onto the operand stack, in the original order.

The dup2 instruction must not be used unless each of word1 and word2 is a word that contains a 32-bit data type or both together are the two words of a single 64-bit datum.

Notes Except for restrictions preserving the integrity of 64-bit data types, the dup2 instruction operates on untyped words, ignoring the types of the data they contain.


dup2_x1

Operation Duplicate top two operand stack words and put three down

dup2_x1


Forms dup2_x1 = 93 (0x5d)

Stack ..., word3, word2, word1 ..., word2, word1, word3, word2, word1

Description The top two words on the operand stack are duplicated and the copies inserted, in the original order, three words down in the operand stack.

The dup2_x1 instruction must not be used unless each of word1 and word2 is a word that contains a 32-bit data type or both together are the two words that contain a single 64-bit datum, and unless word3 is a word that contains a 32-bit data type.

Notes Except for restrictions preserving the integrity of 64-bit data types, the dup2_x1 instruction operates on untyped words, ignoring the types of the data they contain.


dup2_x2

Operation Duplicate top two operand stack words and put four down

dup2_x2


Forms dup2_x2 = 94 (0x5e)

Stack ..., word4, word3, word2, word1 ..., word2, word1, word4, word3, word2, word1

Description The top two words on the operand stack are duplicated and the copies inserted, in the original order, four words down in the operand stack.

The dup2_x2 instruction must not be used unless each of word1 and word2 is a 32-bit data type or both together are the two words of a single 64-bit datum, and unless word3 and word4 are each a word that contains a 32-bit data type or both together are the two words of a single 64-bit datum.

Notes Except for restrictions preserving the integrity of 64-bit data types, the dup2_x2 instruction operates on untyped words, ignoring the types of the data they contain.


f2d

Operation Convert float to double

f2d


Forms f2d = 141 (0x8d)

Stack ..., value ..., result.word1, result.word2

Description The value on the top of the operand stack must be of type float. It is popped from the operand stack and converted to a double. The result is pushed onto the operand stack.

Notes The f2d instruction performs a widening primitive conversion (§2.6.2). Because all values of type float are exactly representable by type double, the conversion is exact.


f2i

Operation Convert float to int

f2i


Forms f2i = 139 (0x8b)

Stack ..., value ..., result

Description The value on the top of the operand stack must be of type float. It is popped from the operand stack and converted to an int. The result is pushed onto the operand stack:

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


Contents | Prev | Next | Index

Java Virtual Machine Specification

Copyright © 1996, 1997 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to [email protected]