fsub

Subtract two floats

Bytecode

Type Description
u1 fsub opcode = 0x66 (102)

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

Description

Pops two single-precision floating point numbers off the operand stack, subtracts the top one from the second (i.e. computes value2 - value1), and pushes the single-precision result back onto the stack. Subtraction is done according to IEEE 754 rules for single precision floating point numbers.

Both value1 and value2 must be of type float. The values are popped from the operand stack. The float result is value1 - value2. The result is pushed onto the operand stack.

For float subtraction, it is always the case that a-b produces the same result as a+(-b). However, for the fsub 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 an fsub instruction never throws a runtime exception.