# Value operations

Arithmetic operator expressions allow computation of new values. Attributes are treated as pure values when used in an arithmetic operator expression.

## [](#_quick_reference)Quick reference

  

Precedence

Operator

Name

1

`^`

exponentiation (power)

2

`*`

multiplication

2

`/`

division

2

`%`

modulo (remainder)

3

`+`

addition

3

`-`

subtraction

Parentheses (`()`) may be used to override the precedence. The sub-expressions in parentheses are always evaluated first.

```typeql
(1 + 2) * 3 == 9
```

## [](#_function_like_operators)Function-like operators

TypeQL provides several built-in functions for common mathematical and list operations:

### [](#_mathematical_functions)Mathematical functions

`round(x)`

Returns the provided numeric argument rounded to the nearest integer. If the value is half-way between two integers, rounds to the nearest even integer.

```typeql
round(3.7) == 4
round(3.2) == 3
round(-3.7) == -4
round(3.5) == 4
round(4.5) == 4
```

`ceil(x)`

Returns the provided numeric argument rounded to the nearest greater integer (ceiling).

```typeql
ceil(3.2) == 4
ceil(3.7) == 4
ceil(-3.2) == -3
```

`floor(x)`

Returns the provided numeric argument rounded to the nearest lesser integer (floor).

```typeql
floor(3.2) == 3
floor(3.7) == 3
floor(-3.2) == -4
```

`abs(x)`

Returns the absolute value of the provided numeric argument.

```typeql
abs(5) == 5
abs(-5) == 5
abs(0) == 0
```

### [](#_comparison_functions)Comparison functions

`min(x, y)`

Returns the minimum value of the two provided numeric arguments.

```typeql
min(10, 12) == 10
min(3.5, 2.1) == 2.1
min(-5, -3) == -5
```

`max(x, y)`

Returns the maximum value of the two provided numeric arguments.

```typeql
max(10, 12) == 12
max(3.5, 2.1) == 3.5
max(-5, -3) == -3
```

### [](#_string_functions)String functions

`len(x)`

Returns the length of the provided string argument in code points (Unicode Scalar Values).

```typeql
len("hello") == 5
len("") == 0
len("こんにちは") == 5
len("⭐") == 1
len("❤️‍🔥") == 4
```

[Literals](../literals/index.md) [Function calls](../function-calls/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/typeql-reference/modules/ROOT/pages/expressions/value-operations.adoc) Edit this page on GitHub.