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

Arithmetic

Arithmetic operations (*, /, %, +, -) follow customary syntax and semantics and are left-associative with multiplication and division having precedence over addition and subtraction. % is the modulo operator.

Unary Sign

Any number may be signed with a unary operator having the form:

- <expr>

and

+ <expr>

where <expr> is any expression that results in a number type.

Example


# spq
values 2*3+1, 11%5, 1/0, "foo"+"bar", +1, -1
# input

# expected output
7
1
error("divide by zero")
"foobar"
1
-1