LANGUAGE » RUST

Numbers

Methods

MethodDescription
roundRound to nearest whole number.
floorLargest integer less than or equal to number.
ceilSmallest integer greater than or equal to number.
truncInteger part without fractional digits.

Example:

rust
let pi = 3.141592;
let round_pi = pi.round();

Update reference

If updating a number in a function that received it as &mut:

rust
fn update_counter(&mut count) {
    *count += 1;
}