Skip to main content
Version: v1.6.0

abs

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 a various numbers:

echo '1 -1 0 -1.0 -1(int8) 1(uint8) "foo"' | zq -z 'yield abs(this)' -

=>

1
1
0
1.
1
1(uint8)
error("abs: not a number: \"foo\"")