Absolute value, minimum and maximum v0.1.0

Source
The magnitude of a floating-point value and the smaller or larger of two.

Abs

pub func Abs(x: float64) -> float64
pub func Abs(x: float32) -> float32

Computes the absolute value of x at float32 precision. Widening a finite float32 to float64 and narrowing its magnitude back is exact. As with the wide overload, either signed zero becomes +0.0, either infinity becomes positive infinity, and a NaN remains a NaN.

OverloadSummary
pub func Abs(x: float64) -> float64Computes the absolute value of x.
pub func Abs(x: float32) -> float32Computes the absolute value of x at float32 precision.

Source

Parameters

NameTypeDescription
xfloat64 / float32value whose magnitude is returned

Returns: x without its sign

Max

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

Selects the larger of a and b. A NaN loses to a number, so one NaN returns the other argument and two NaNs return a NaN. When both arguments are zeros, a positive zero wins.

OverloadSummary
pub func Max(a: float64, b: float64) -> float64Selects the larger of a and b.
pub func Max(a: float32, b: float32) -> float32Selects the larger of a and b at float32 precision.

Source

Parameters

NameTypeDescription
afloat64 / float32first value to compare
bfloat64 / float32second value to compare

Returns: the larger non-NaN value, or a NaN when both arguments are NaNs

Min

pub func Min(a: float64, b: float64) -> float64
pub func Min(a: float32, b: float32) -> float32

Selects the smaller of a and b. A NaN loses to a number, so one NaN returns the other argument and two NaNs return a NaN. When both arguments are zeros, a negative zero wins.

OverloadSummary
pub func Min(a: float64, b: float64) -> float64Selects the smaller of a and b.
pub func Min(a: float32, b: float32) -> float32Selects the smaller of a and b at float32 precision.

Source

Parameters

NameTypeDescription
afloat64 / float32first value to compare
bfloat64 / float32second value to compare

Returns: the smaller non-NaN value, or a NaN when both arguments are NaNs