# Numbers

Numbers in RuLA represent numeric values, including both integers and decimal numbers.

## Creating Numbers

Write numbers directly without quotes:

```
42          # Integer
-7          # Negative number
3.14159     # Decimal number
0.5         # Decimal less than 1
```

## Number Operations

### Arithmetic

```
5 + 3           # Addition: 8
10 - 4          # Subtraction: 6
3 * 4           # Multiplication: 12
15 / 3          # Division: 5
17 // 5         # Integer division: 3
17 % 5          # Modulo (remainder): 2
2 ** 3          # Exponentiation: 8
```

### Comparison

```
5 > 3           # Greater than: True
5 >= 5          # Greater than or equal: True
3 < 5           # Less than: True
4 <= 5          # Less than or equal: True
```

### Rounding and Precision

```
ROUND(3.14159)          # Round to nearest integer: 3
ROUND(3.14159, 2)       # Round to 2 decimals: 3.14
FLOOR(3.7)              # Round down: 3
CEIL(3.2)               # Round up: 4
```

### Absolute Value and Sign

```
ABS(-5)                 # Returns 5
SIGN(-5)                # Returns -1
SIGN(5)                 # Returns 1
SIGN(0)                 # Returns 0
```

## Useful Number Functions

| Function                                                                              | Description                  | Example                            |
| ------------------------------------------------------------------------------------- | ---------------------------- | ---------------------------------- |
| [`SUM`](/rule-language/operators/mathematical-operators/sum.md)                       | Sum of all numbers in a list | `SUM([1, 2, 3])` → `6`             |
| [`AVG`](/rule-language/operators/mathematical-operators/avg.md)                       | Average of numbers in a list | `AVG([1, 2, 3])` → `2`             |
| [`MIN`](/rule-language/operators/mathematical-operators/min.md)                       | Smallest number in a list    | `MIN([3, 1, 2])` → `1`             |
| [`MAX`](/rule-language/operators/mathematical-operators/max.md)                       | Largest number in a list     | `MAX([3, 1, 2])` → `3`             |
| [`ROUND`](/rule-language/operators/mathematical-operators/round.md)                   | Round to nearest integer     | `ROUND(2.5)` → `3`                 |
| [`ROUND(number, decimals)`](/rule-language/operators/mathematical-operators/round.md) | Round to N decimal places    | `ROUND(3.14159, 2)` → `3.14`       |
| [`FLOOR`](/rule-language/operators/mathematical-operators/floor.md)                   | Round down to integer        | `FLOOR(3.9)` → `3`                 |
| [`CEIL`](/rule-language/operators/mathematical-operators/ceil.md)                     | Round up to integer          | `CEIL(3.1)` → `4`                  |
| [`ABS`](/rule-language/operators/mathematical-operators/abs.md)                       | Absolute value               | `ABS(-5)` → `5`                    |
| [`SIGN`](/rule-language/operators/mathematical-operators/sign.md)                     | Sign of number (-1, 0, 1)    | `SIGN(-5)` → `-1`                  |
| [`SQRT`](/rule-language/operators/mathematical-operators/sqrt.md)                     | Square root                  | `SQRT(16)` → `4`                   |
| [`CLAMP`](/rule-language/operators/mathematical-operators/clamp.md)                   | Constrain to range           | `CLAMP(10, 0, 5)` → `5`            |
| [`COMB`](/rule-language/operators/mathematical-operators/comb.md)                     | Combinations (n choose k)    | `COMB(5, 2)` → `10`                |
| [`SUM_PRODUCT`](/rule-language/operators/mathematical-operators/sum_product.md)       | Sum of products              | `SUM_PRODUCT([1,2], [3,4])` → `11` |

## Working with Lists of Numbers

Aggregate functions work on lists:

```
numbers = [10, 20, 30, 40]
SUM(numbers)        # 100
AVG(numbers)        # 25
MIN(numbers)        # 10
MAX(numbers)        # 40
```

## Type Checking

To check if a value is a number:

```
# Numbers are always known (not None/unknown)
known(42)           # True
unknown(42)         # False
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.atfinity.io/rule-language/data-types/numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
