# manual-is-multiple-of

Prefer isMultipleOf over a remainder comparison with zero

Comparing an integer remainder with zero manually tests divisibility.
Instead, you SHOULD call `.isMultipleOf()` on the dividend.

A zero divisor returns true exactly when the dividend is zero.
The smallest signed value with a divisor of `-1` returns true without overflowing.

- Category: style
- Level: warning
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
function aligned(value: uint32, alignment: uint32): boolean {
    return value % alignment === 0;
}
```

## Accepted

```ds title="main.ds"
function aligned(value: uint32, alignment: uint32): boolean {
    return value.isMultipleOf(alignment);
}
```

## Prior art

- [Clippy · manual_is_multiple_of](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_multiple_of)

[language/linter/src/rules/style/manual_is_multiple_of.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/manual_is_multiple_of.rs#L8)
