---
name: "a % b"
type: command
operator: "%"
status: ok
groups: ["Math"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/a_%25_b
revid: 318435
updated: 2022-05-13T07:44:52Z
---

# a % b

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

Alias: [mod](../commands/mod.md)

## Description

Remainder of *a* divided by *b*.

## Syntax

```sqf
a % b
```

**Parameters:**

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

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

## Examples

### Example 1

```sqf
4.5 % 3 // result is 1.5
```

## See also

[mod](../commands/mod.md) · [Operators](../topics/Operators.md)

## Community notes

**Hoz** — 2006-04-16

- Remainder is calculated in real domain.
- [a % b](../commands/a_~25_b.md) is identical to [mod](../commands/mod.md)
You can use % 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 % 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.

---

**SilentSpike** — 2015-07-21

Be careful when dealing with negative numbers. The way a modulo operation treats negatives differs between languages. In SQF truncated division is used, hence:

```sqf
-12 % -10 = -2
-12 %  10 = -2
 12 % -10 =  2
 12 %  10 =  2
```

<sub>Source: [BI Community Wiki — a % b](https://community.bistudio.com/wiki/a_%25_b) (revision 318435).</sub>
