> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Numeric functions

> Numeric functions resolve an overload from the input types. Cast an input explicitly when an example needs floating-point behavior. Most required null arguments produce NULL. Inval

ReferenceApplies to: Unified engine deployments

Numeric functions resolve an overload from the input types. Cast an input explicitly when an example needs floating-point behavior. Most required null arguments produce NULL. Invalid domains, overflow, or unsupported conversions can produce errors.

## Magnitude and rounding

| Function | Returns | Meaning |
| - | - | - |
| `abs(number)` | Numeric | Absolute value |
| `ceil(number)`, `floor(number)` | Numeric | Round toward positive or negative infinity |
| `round(number[, digits])` | Numeric | Round to a precision |
| `trunc(number[, digits])` | Numeric | Truncate fractional digits |
| `signum(number)` | Numeric | Sign of the argument |

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT i_item_sk,
       ABS(CAST(i_current_price AS DOUBLE)) AS magnitude,
       CEIL(CAST(i_current_price AS DOUBLE)) AS rounded_up,
       FLOOR(CAST(i_current_price AS DOUBLE)) AS rounded_down,
       ROUND(CAST(i_current_price AS DOUBLE), 1) AS one_decimal
FROM demo.tpcds.item
WHERE i_current_price IS NOT NULL
ORDER BY i_item_sk
LIMIT 5;
```

## Powers, roots, and logarithms

| Function | Returns | Meaning |
| - | - | - |
| `power(base, exponent)`, `pow(base, exponent)` | Numeric | Exponentiation |
| `sqrt(number)` | Numeric | Square root |
| `exp(number)` | Floating point | Exponential |
| `ln(number)` | Floating point | Natural logarithm |
| `log10(number)` | Floating point | Base-10 logarithm |
| `sin(number)`, `cos(number)`, `tan(number)` | Floating point | Trigonometric functions with radians |

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT i_item_sk,
       SQRT(CAST(i_current_price AS DOUBLE)) AS square_root,
       POWER(CAST(i_current_price AS DOUBLE), 2.0) AS squared_price,
       LN(CAST(i_current_price AS DOUBLE)) AS log_price
FROM demo.tpcds.item
WHERE i_current_price > 0
ORDER BY i_item_sk
LIMIT 5;
```

## Random values and exact values

`random()` and alias `rand()` produce a non-deterministic floating-point value. Do not use random output as an expected-result fixture. Decimal calculations preserve declared precision differently from DOUBLE; choose the type intentionally for money and exact comparisons.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT i_item_sk, RANDOM() AS sample_value
FROM demo.tpcds.item
ORDER BY i_item_sk
LIMIT 3;
```

A numeric function resolving successfully does not guarantee that an unsupported arithmetic expression around it will compile. See [operators](https://docs.e6data.com/transformation/sql/operators.md) for integer arithmetic and cast restrictions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.