Tsallaka zuwa abun ciki
Justice Tech School

Numbers and Math

Float methods: sqrt, powi, abs, floor, ceil, round. Integer methods: pow, abs, min, max.

Example
fn main() {
    let x = 16.0_f64;
    println!("{} {} {} {}", x.sqrt(), x.powi(2), (-3.5_f64).abs(), 2.5_f64.round());
    println!("{} {}", 2_i32.pow(10), 7_i32.max(9));
}

Result

4 256 3.5 3
1024 9

Exercise

Square root.

x.()

Quiz Test

Which raises to an int power?

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