Skip to content
Justice Tech School

Operators

Arithmetic, comparison, logical and bitwise operators. Integer division truncates and overflow panics in debug.

Example
fn main() {
    let a = 7; let b = 2;
    println!("{} {} {}", a / b, a % b, a as f64 / b as f64);
    println!("{} {}", a > b && b > 0, a << 1);
}

Result

3 1 3.5
true 14

Exercise

Remainder.

7  2

Quiz Test

What is 7 / 2 for ints?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.