std-method
Floating-point floor and ceil
Round toward negative or positive infinity. For example, rounding a required number of boxes upward avoids leaving items unpacked. Expected stdout (not executed): -3 -2 3 Common mistake: floor is not truncation toward zero for negative numbers.
Formal Syntax & Structure
rust syntaxrust
x.floor() -> f64; x.ceil() -> f64Working Example
Example Snippetrust
fn main() { let x = -2.25_f64; println!("{} {}", x.floor(), x.ceil()); println!("{}", (10.0_f64/4.0).ceil());}