ABS

ABS(value)[source]

Returns the absolute value of a number or numeric array.

The ABS function computes the absolute value of the input. For scalar numbers, it returns the positive equivalent. For array inputs the absolute value is computed element-wise and an array type is returned.

Parameters:

value (int | float | Operand) –

The numeric input whose absolute value is to be computed.

Supported types:

  • INTEGER

  • DECIMAL

  • INTEGER_ARRAY

  • DECIMAL_ARRAY

Return type:

Formula

Returns:

A Formula object representing the absolute value of the input. For arrays, the absolute value is computed element-wise.

Supported types:

  • INTEGER

  • DECIMAL

  • INTEGER_ARRAY

  • DECIMAL_ARRAY

Raises:

ValueError – If the input is not a numeric type.

Examples

Absolute value of a scalar:

ABS(-5)
# Returns 5

Absolute value of a decimal:

ABS(-3.7)
# Returns 3.7

Absolute value of a numeric array:

ABS([-1, -2, 3])
# Returns [1, 2, 3]