---
name: "mod"
type: command
status: ok
groups: ["Math"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/mod
revid: 339102
updated: 2023-04-26T10:54:26Z
---

# mod

*Command · Math · Arma 3 v0.50 · introduced in Operation Flashpoint v1.00*

Alias: [a % b](../commands/a_~25_b.md)

## Description

Remainder of a divided by b.

## Syntax

```sqf
a mod b
```

**Parameters:**

- `a`: [Number](../topics/Number.md)
- `b`: [Number](../topics/Number.md)

**Returns:** [Number](../topics/Number.md)

## Examples

### Example 1

```sqf
_remaining = 5 mod 2; // returns 1, as 5 divided by 2 is 2 × 2 + 1
```

## See also

Math Commands · [Operators](../topics/Operators.md) · [a % b](../commands/a_~25_b.md)

## Community notes

**Hoz** — 2006-04-16

- Remainder is calculated in real domain.
- mod is identical to [a % b](../commands/a_~25_b.md)
You can use mod to round a decimal number down to the nearest whole number. For example: If you wanted to use the command random to generate a whole number between 0 and 5, you could put this in a script:

```sqf
_rand = random 6;
_num = _rand - (_rand mod 1);
```

In A1, the new commands [round](../commands/round.md), [floor](../commands/floor.md) or [ceil](../commands/ceil.md) would be the easier way to round.

<sub>Source: [BI Community Wiki — mod](https://community.bistudio.com/wiki/mod) (revision 339102).</sub>
