Returns the next representable floating-point value greater than the input value. This function takes a floating-point value that implements the FloatBits trait, calculates the next representable value greater than the input, and returns it. If the input value is NaN or positive infinity, the function returns the input value. # Examples ``` use datafusion_common::rounding::next_up; let f: f32
(float: F)
| 172 | /// assert_eq!(next_f, 1.0000001); |
| 173 | /// ``` |
| 174 | pub fn next_up<F: FloatBits + Copy>(float: F) -> F { |
| 175 | let bits = float.to_bits(); |
| 176 | if float.float_is_nan() || bits == F::infinity().to_bits() { |
| 177 | return float; |
| 178 | } |
| 179 | |
| 180 | let abs = bits & F::CLEAR_SIGN_MASK; |
| 181 | let next_bits = if bits == F::ZERO { |
| 182 | F::TINY_BITS |
| 183 | } else if abs == F::ZERO { |
| 184 | F::ZERO |
| 185 | } else if bits == abs { |
| 186 | bits + F::ONE |
| 187 | } else { |
| 188 | bits - F::ONE |
| 189 | }; |
| 190 | F::from_bits(next_bits) |
| 191 | } |
| 192 | |
| 193 | /// Returns the next representable floating-point value smaller than the input value. |
| 194 | /// |
searching dependent graphs…