# abs

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/numeric/abs)

Returns the absolute value of a number.

## Syntax

```scopeql
abs(<expr>)
```

## Arguments

| Argument | Type                      | Description  |
| -------- | ------------------------- | ------------ |
| `<expr>` | `int`, `uint`, or `float` | Input value. |

## Returns

Returns the same type as the input. Returns NULL in either case:

* The input is NULL.
* The input is the minimum `int`, -9223372036854775808. Its absolute value is outside the `int` range.

## Examples

Compare the magnitude of positive and negative inventory corrections without losing the signed adjustment.

```scopeql
VALUES ('evt-17', -12), ('evt-42', 5), ('evt-63', -2)
SELECT $0 AS event_id, $1 AS stock_delta
SELECT event_id, stock_delta, abs(stock_delta) AS changed_units
ORDER BY changed_units DESC
```

```text
+----------+-------------+---------------+
| event_id | stock_delta | changed_units |
+----------+-------------+---------------+
| evt-17   | -12         | 12            |
| evt-42   | 5           | 5             |
| evt-63   | -2          | 2             |
+----------+-------------+---------------+
```
