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

Function

abs — absolute value of a number

Synopsis

abs(n: number) -> number

Description

The abs function returns the absolute value of its argument n, which must be a numeric type.

Examples


Absolute value of various numbers

# spq
values abs(this)
# input
1
-1
0
-1.0
-1::int8
1::uint8
"foo"
# expected output
1
1
0
1.
1::int8
1::uint8
error({message:"abs: not a number",on:"foo"})