Max v0.1.0

Source
Returns the larger of two values.

Package: Math

Signature

func Max(a: float64, b: float64) -> float64;
func Max(a: float32, b: float32) -> float32;

Parameters

NameTypeDescription
afloat64 / float32The first value.
bfloat64 / float32The second value.

Returns

The larger of a and b. A NaN loses to anything else — Max(NaN, y) is y and Max(x, NaN) is x — and only two NaNs produce a NaN. When a and b compare equal, the sign of a zero still decides: Max(0.0, -0.0) is 0.0.

Example

import Math::Max;

func Main() -> int {
    let a = Max(3.0, 7.0);  // 7.0
    let b = Max(0.0, -0.0); // 0.0
    return 0;
}

See also

  • Math — the package overview
  • Min — the larger value's counterpart
  • Abs — magnitude of a single value