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

# Operators

> Logical, equality, comparison and arithmetic operators, and their precedence.

## Precedence

Operators are listed from lowest to highest precedence. All binary operators are left-associative. Use parentheses to change the order of evaluation.

| Precedence | Operators | Operands |
| - | - | - |
| 1 (lowest) | `\|\|` | Booleans. Short-circuits. |
| 2 | `&&` | Booleans. Short-circuits. |
| 3 | `==` `!=` | Any values |
| 4 | `<` `<=` `>` `>=` | Two numbers, or two strings |
| 5 | `+` `-` | Numbers. `+` also concatenates strings. |
| 6 | `*` `/` | Numbers |
| 7 (highest) | Unary `!`, unary `-` | Boolean, number |

There's no modulo operator (`%`), no compound assignment (`+=`) and no increment or decrement operator (`++`, `--`).

## Logical operators

`!` (not), `&&` (and) and `||` (or) require booleans. Using them with any other type is an error. There's no "truthiness": `0`, `""` and `null` are not treated as `false`.

`&&` and `||` short-circuit: the right side is evaluated only when it's needed.

```kotlin theme={null}
request Logic {
    const score = 85
    const late = false
    return score >= 80 && !late // true
}
```

## Equality

`==` and `!=` work on any two values.

* **Numbers** are compared by value across types, so `1 == 1.0` is `true`.
* **Objects and lists** are compared deeply, by contents rather than identity: `[1, 2] == [1, 2]` is `true`.
* **Values of different non-numeric types** are never equal. For example, `null == false` is `false` and `"1" == 1` is `false`.

## Comparison

`<`, `<=`, `>` and `>=` compare two numbers by value, or two strings lexicographically. Comparing any other combination, such as a number with a string, is an error.

```kotlin theme={null}
2 < 10.5       // true
"apple" < "b"  // true
```

## Arithmetic

`+`, `-`, `*` and `/` work on numbers. The result type depends on the operand types:

| Operands | Result |
| - | - |
| Both `int32` | `int32` |
| Either is `int64`, neither is `decimal` | `int64` |
| Either is `decimal` | `decimal` |

### Integer arithmetic

* A result outside the range of its type is an overflow error. Integers never wrap around.
* Integer division truncates toward zero: `7 / 2` is `3` and `-7 / 2` is `-3`.

To get a fractional result from two integers, make one operand a decimal: `7 / 2.0` is `3.5`.

### Decimal arithmetic

* Addition, subtraction and multiplication are exact.
* Division rounds half away from zero to 10 decimal places, or to the number of decimal places of the more precise operand if that's greater. For example, `1 / 3.0` is `0.3333333333`.

### Division by zero

Dividing by zero is an error for both integers and decimals.

## String concatenation

When either side of `+` is a string, the other side is converted to a string and the two are joined. Values are converted the same way as in [string interpolation](/language/expressions#string-interpolation).

```kotlin theme={null}
request Concatenation {
    return "Count: " + 5 + ", ok: " + true // "Count: 5, ok: true"
}
```

This is the only implicit conversion to a string. `-`, `*` and `/` never accept strings.

## Unary minus

Unary `-` negates a number: `-5`, `-price`, `-(a + b)`.


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