fneg

Negate a float

Bytecode

Type Description
u1 fneg opcode = 0x76 (118)

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

Description

Removes the top single-precision float from the operand stack, negates it (i.e. inverts its sign), and pushes the negated result back onto the stack.

Note that, in IEEE floating point arithmetic, negation is not quite the same as subtracting from 0. IEEE has two zeros, +0.0 and -0.0. fneg applied to +0.0 is -0.0, whereas (+0.0 minus +0.0) is +0.0.

The value must be of type float. It is popped from the operand stack. The float result is the arithmetic negation of value, -value. The result is pushed onto the operand stack.

For float 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 float.

Special cases of interest: