---
title: Operator Functions
description:
  Standard library operator functions for mathematical and logical operations
---

## and_bool

`and_bool` returns the binary AND of the left- and right-hand-side arguments.

### Inputs

| Name  | Type | Description     |
| ----- | ---- | --------------- |
| `lhs` | bool | A boolean value |
| `rhs` | bool | A boolean value |

### Output

| Name    | Type | Description                                          |
| ------- | ---- | ---------------------------------------------------- |
| `value` | bool | The result of a binary AND between the two arguments |

```hcl
output "my_bool" {
  value = false && true
}
// > my_bool: false
```

---

## or_bool

`or_bool` returns the binary OR of the left- and right-hand-side arguments.

### Inputs

| Name  | Type | Description     |
| ----- | ---- | --------------- |
| `lhs` | bool | A boolean value |
| `rhs` | bool | A boolean value |

### Output

| Name    | Type | Description                                         |
| ------- | ---- | --------------------------------------------------- |
| `value` | bool | The result of a binary OR between the two arguments |

```hcl
output "my_bool" {
  value = false || true
}
// > my_bool: true
```

---

## div

`div` returns the integer division of the left-hand-side argument by the
right-hand-side argument, rounding any remainder down to the nearest integer.

### Inputs

| Name  | Type    | Description  |
| ----- | ------- | ------------ |
| `lhs` | integer | The dividend |
| `rhs` | integer | The divisor  |

### Output

| Name    | Type    | Description                                        |
| ------- | ------- | -------------------------------------------------- |
| `value` | integer | The result of dividing the dividend by the divisor |

```hcl
output "my_int" {
  value = 11 / -3
}
// > my_int: -3
```

---

## eq

`eq` returns `true` if the left- and right-hand-side arguments are equal and
`false` if they are not.

### Inputs

| Name  | Type | Description |
| ----- | ---- | ----------- |
| `lhs` | any  | Any value   |
| `rhs` | any  | Any value   |

### Output

| Name    | Type | Description                                            |
| ------- | ---- | ------------------------------------------------------ |
| `value` | bool | The result of an equality check between the two inputs |

```hcl
output "is_eq" {
  value = "arg" == "arg"
}
// > is_eq: true
```

---

## gt

`gt` returns `true` if the left-hand-side argument is greater than the
right-hand-side argument.

### Inputs

| Name  | Type                       | Description        |
| ----- | -------------------------- | ------------------ |
| `lhs` | integer \| float \| string | A comparable value |
| `rhs` | integer \| float \| string | A comparable value |

### Output

| Name    | Type | Description                                                                                        |
| ------- | ---- | -------------------------------------------------------------------------------------------------- |
| `value` | bool | The result of checking if the left-hand-side argument is greater than the right-hand-side argument |

```hcl
output "is_gt" {
  value = 2 > 1
}
// > is_gt: true
```

---

## gte

`gte` returns `true` if the left-hand-side argument is greater than or equal to
the right-hand-side argument.

### Inputs

| Name  | Type                       | Description        |
| ----- | -------------------------- | ------------------ |
| `lhs` | integer \| float \| string | A comparable value |
| `rhs` | integer \| float \| string | A comparable value |

### Output

| Name    | Type | Description                                                                                                    |
| ------- | ---- | -------------------------------------------------------------------------------------------------------------- |
| `value` | bool | The result of checking if the left-hand-side argument is greater than or equal to the right-hand-side argument |

```hcl
output "is_gte" {
  value = 2 >= 2
}
// > is_gte: true
```

---

## lt

`lt` returns `true` if the left-hand-side argument is less than the
right-hand-side argument.

### Inputs

| Name  | Type                       | Description        |
| ----- | -------------------------- | ------------------ |
| `lhs` | integer \| float \| string | A comparable value |
| `rhs` | integer \| float \| string | A comparable value |

### Output

| Name    | Type | Description                                                                                     |
| ------- | ---- | ----------------------------------------------------------------------------------------------- |
| `value` | bool | The result of checking if the left-hand-side argument is less than the right-hand-side argument |

```hcl
output "is_lt" {
  value = 2 < 1
}
// > is_lt: false
```

---

## lte

`lte` returns `true` if the left-hand-side argument is less than or equal to the
right-hand-side argument.

### Inputs

| Name  | Type                       | Description        |
| ----- | -------------------------- | ------------------ |
| `lhs` | integer \| float \| string | A comparable value |
| `rhs` | integer \| float \| string | A comparable value |

### Output

| Name    | Type | Description                                                                                                 |
| ------- | ---- | ----------------------------------------------------------------------------------------------------------- |
| `value` | bool | The result of checking if the left-hand-side argument is less than or equal to the right-hand-side argument |

```hcl
output "is_lte" {
  value = 2 <= 2
}
// > is_lte: true
```

---

## neq

`neq` returns `true` if the left- and right-hand-side arguments are not equal
and `false` otherwise.

### Inputs

| Name  | Type | Description                |
| ----- | ---- | -------------------------- |
| `lhs` | any  | A value to compare         |
| `rhs` | any  | A value to compare against |

### Output

| Name    | Type | Description                                                   |
| ------- | ---- | ------------------------------------------------------------- |
| `value` | bool | The result of a negated equality check between the two inputs |

```hcl
output "is_neq" {
  value = "arg" != "arg"
}
// > is_neq: false
```

---

## minus

`minus` returns the result of subtracting the right-hand-side `integer` argument
from the left-hand-side `integer` argument.

### Inputs

| Name  | Type    | Description    |
| ----- | ------- | -------------- |
| `lhs` | integer | The minuend    |
| `rhs` | integer | The subtrahend |

### Output

| Name    | Type    | Description                             |
| ------- | ------- | --------------------------------------- |
| `value` | integer | The result of the subtraction operation |

```hcl
output "my_integer" {
  value = 10 - 6
}
// > my_integer: 4
```

---

## modulo

`modulo` returns the remainder of dividing the left-hand-side `integer` argument
by the right-hand-side `integer` argument.

### Inputs

| Name  | Type    | Description  |
| ----- | ------- | ------------ |
| `lhs` | integer | The dividend |
| `rhs` | integer | The divisor  |

### Output

| Name    | Type    | Description                             |
| ------- | ------- | --------------------------------------- |
| `value` | integer | The remainder of the division operation |

```hcl
output "my_mod" {
    value = 10 % 3
}
// > my_mod: 1
```

---

## multiply

`multiply` returns the product of the left-hand-side `integer` argument and the
right-hand-side `integer` argument.

### Inputs

| Name  | Type    | Description        |
| ----- | ------- | ------------------ |
| `lhs` | integer | The first operand  |
| `rhs` | integer | The second operand |

### Output

| Name    | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| `value` | integer | The result of the multiplication operation |

```hcl
output "my_product" {
    value = 10 * 5
}
// > my_product: 50
```

---

## add

`add` returns the sum of the left-hand-side `integer` argument and the
right-hand-side `integer` argument.

### Inputs

| Name  | Type    | Description        |
| ----- | ------- | ------------------ |
| `lhs` | integer | The first operand  |
| `rhs` | integer | The second operand |

### Output

| Name    | Type    | Description                          |
| ------- | ------- | ------------------------------------ |
| `value` | integer | The result of the addition operation |

```hcl
output "my_sum" {
    value = 10 + 5
}
// > my_sum: 15
```

---

## neg_integer

Returns the negation of the given integer.

### Inputs

| Name    | Type    | Description      |
| ------- | ------- | ---------------- |
| `value` | integer | An integer value |

### Output

| Name    | Type    | Description               |
| ------- | ------- | ------------------------- |
| `value` | integer | The negated integer value |

---

## not_bool

Returns the logical negation of the given boolean value.

### Inputs

| Name    | Type | Description     |
| ------- | ---- | --------------- |
| `value` | bool | A boolean value |

### Output

| Name    | Type | Description                                     |
| ------- | ---- | ----------------------------------------------- |
| `value` | bool | The logical negation of the input boolean value |
