micromath/float/
ceil.rs

1//! Floating point ceiling approximation for a single-precision float.
2
3use super::F32;
4
5impl F32 {
6    /// Returns the smallest integer greater than or equal to a number.
7    pub fn ceil(self) -> Self {
8        -(-self).floor()
9    }
10}
11
12#[cfg(test)]
13mod tests {
14    use super::F32;
15
16    #[test]
17    fn sanity_check() {
18        assert_eq!(F32(-1.1).ceil().0, -1.0);
19        assert_eq!(F32(-0.1).ceil().0, 0.0);
20        assert_eq!(F32(0.0).ceil().0, 0.0);
21        assert_eq!(F32(1.0).ceil().0, 1.0);
22        assert_eq!(F32(1.1).ceil().0, 2.0);
23        assert_eq!(F32(2.9).ceil().0, 3.0);
24    }
25}