Contents Prev Next Up


3.8 Arithmetic Instructions

iadd

Integer add
 
iadd = 96

Stack: ..., value1, value2 => ..., result

value1 and value2 must be integers. The values are added and are replaced on the stack by their integer sum.

ladd

Long integer add
 
ladd = 97

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be long integers. The values are added and are replaced on the stack by their long integer sum.

fadd

Single floats
 
fadd = 98
add

Stack: ..., value1, value2 => ..., result

value1 and value2 must be single-precision floating point numbers. The values are added and are replaced on the stack by their single-precision floating point sum.

dadd

Double floats
 
dadd = 99
add

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be double-precision floating point numbers. The values are added and are replaced on the stack by their double-precision floating point sum.

isub

Integer subtract
 
isub = 100

Stack: ..., value1, value2 => ..., result

value1 and value2 must be integers. value2 is subtracted from value1, and both values are replaced on the stack by their integer difference.

lsub

Long integer
 
lsub = 101
subtract

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be long integers. value2 is subtracted from value1, and both values are replaced on the stack by their long integer difference.

fsub

Single float
 
fsub = 102
subtract

Stack: ..., value1, value2 => ..., result

value1 and value2 must be single-precision floating point numbers. value2 is subtracted from value1, and both values are replaced on the stack by their single-precision floating point difference.

dsub

Double float subtract
 
dsub = 103

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be double-precision floating point numbers. value2 is subtracted from value1, and both values are replaced on the stack by their double-precision floating point difference.

imul

Integer multiply
 
imul = 104

Stack: ..., value1, value2 => ..., result

value1 and value2 must be integers. Both values are replaced on the stack by their integer product.

lmul

Long integer multiply
 
imul = 105

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be long integers. Both values are replaced on the stack by their long integer product.

fmul

Single float multiply
 
fmul = 106

Stack: ..., value1, value2 => ..., result

value1 and value2 must be single-precision floating point numbers. Both values are replaced on the stack by their single-precision floating point product.

dmul

Double float multiply
 
dmul = 107

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be double-precision floating point numbers. Both values are replaced on the stack by their double-precision floating point product.

idiv

Integer divide
 
idiv = 108

Stack: ..., value1, value2 => ..., result

value1 and value2 must be integers. value1 is divided by value2, and both values are replaced on the stack by their integer quotient.

The result is truncated to the nearest integer that is between it and 0. An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

ldiv

Long integer divide
 
ldiv = 109

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be long integers. value1 is divided by value2, and both values are replaced on the stack by their long integer quotient.

The result is truncated to the nearest integer that is between it and 0. An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

fdiv

Single float divide
 
fdiv = 110

Stack: ..., value1, value2 => ..., result

value1 and value2 must be single-precision floating point numbers. value1 is divided by value2, and both values are replaced on the stack by their single-precision floating point quotient.

Divide by zero results in the quotient being NaN.

ddiv

Double float divide
 
ddiv = 111

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must be double-precision floating point numbers. value1 is divided by value2, and both values are replaced on the stack by their double-precision floating point quotient.

Divide by zero results in the quotient being NaN.

irem

Integer remainder
 
irem = 112

Stack: ..., value1, value2 => ..., result

value1 and value2 must both be integers. value1 is divided by value2, and both values are replaced on the stack by their integer remainder.

An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

Note: need a description of the integer remainder semantics

lrem

Long integer remainder
 
lrem = 113

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must both be long integers. value1 is divided by value2, and both values are replaced on the stack by their long integer remainder.

An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

Note: need a description of the integer remainder semantics

frem

Single float remainder
 
frem = 114

Stack: ..., value1, value2 => ..., result

value1 and value2 must both be single-precision floating point numbers. value1 is divided by value2, and the quotient is truncated to an integer, and then multiplied by value2. The product is subtracted from value1.The result, as a single-precision floating point number, replaces both values on the stack. result = value1 - (integral_part(value1/value2) * value2), where integral_part() rounds to the nearest integer, with a tie going to the even number.

An attempt to divide by zero results in NaN.

Note: gls to provide a better definition of the floating remainder semantics

drem

Double float remainder
 
drem = 115

Stack: ..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 must both be double-precision floating point numbers. value1 is divided by value2, and the quotient is truncated to an integer, and then multiplied by value2. The product is subtracted from value1.The result, as a double-precision floating point number, replaces both values on the stack. result = value1 - (integral_part(value1/value2) * value2), where integral_part() rounds to the nearest integer, with a tie going to the even number.

An attempt to divide by zero results in NaN.

Note: gls to provide a better definition of the floating remainder semantics

ineg

Integer negate
 
ineg = 116

Stack: ..., value => ..., result

value must be an integer. It is replaced on the stack by its arithmetic negation.

lneg

Long integer
 
lneg = 117
negate

Stack: ..., value-word1, value-word2 => ..., result-word1, result-word2

value must be a long integer. It is replaced on the stack by its arithmetic negation.

fneg

Single float negate
 
fneg = 118

Stack: ..., value => ..., result

value must be a single-precision floating point number. It is replaced on the stack by its arithmetic negation.

dneg

Double float negate
 
dneg = 119

Stack: ..., value-word1, value-word2 => ..., result-word1, result-word2

value must be a double-precision floating point number. It is replaced on the stack by its arithmetic negation.


Contents Prev Next Up