Skip to main content

max

Function max 

Source
pub fn max<T: AsRef<[f32]>>(values: T) -> f32
Expand description

Calculate statistical max for values.

§Nan

Return NaN if the values are empty.

From https://doc.rust-lang.org/std/primitive.f32.html#method.max:

If one of the arguments is NaN, then the other argument is returned. This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs; this function handles all NaNs the same way and avoids maxNum’s problems with associativity. This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal (such as for the case of +0.0 and -0.0), either input may be returned non-deterministically.

§Example

use numeric_statistics::f64::max::*;
let values = &[1.0, 2.0, 4.0];
let max = max(values);
assert_eq!(max, 4.0);