Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Negation

The negation operator denotes the arithmetic negation of its operand.

Process

At runtime:

  1. the operand is evaluated; and
  2. its arithmetic negation is computed, and is the negation's value.

For signed integer types, negation is two's complement negation; negating the minimum value of a signed integer type wraps to itself. For floating-point types, negation follows IEEE 754 semantics.

Negative literal values are formed by applying this operator to a literal; see integer literals.

Assertions

  1. The operand's type is a signed integer type or a floating-point type, and the negation's result has that type.
  2. When an expected type exists, the operand's expected type is that type.

Syntax

negation_operator = minus ;