RS.CLIPPY.INTEGER_DIVISION

Integer division may cause loss of precision

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: integer_division. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for division of integers

Why restrict this?

When outside of some very specific algorithms, integer division is very often a mistake because it discards the remainder.

Example

let x = 3 / 2;
println!("{}", x);

Use instead:

let x = 3f32 / 2f32;
println!("{}", x);