# manual-div-ceil

Prefer divideCeil over an adjusted integer numerator

Adding one less than the divisor before integer division manually computes a ceiling quotient and may overflow the intermediate sum.
Instead, you SHOULD call `.divideCeil()` on the dividend.

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

## Reported

```ds title="main.ds"
function chunks(length: uint32, width: uint32): uint32 {
    return (length + width - 1) / width;
}
```

## Accepted

```ds title="main.ds"
function chunks(length: uint32, width: uint32): uint32 {
    return length.divideCeil(width);
}
```

## Prior art

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

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