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

Unary Operators

Alpha-7 supports unary negation and unary plus.

Example:

Int Value = -10;

Unary negation can also be applied to an expression:

Int Result = -(A + B);

Unary plus is a no-op:

Int Value = +42;

It exists because sometimes a language designer looks at unary minus and thinks, "why should minus get all the attention?"

Precedence

Unary operators bind looser than **. Therefore:

-2 ** 2

is interpreted as:

-(2 ** 2)

which produces:

-4

This is part of the documented language rule that unary operators bind looser than the power operator.


← Previous Next →