Absolute value, minimum and maximum v0.1.0
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.
| Overload | Summary |
|---|---|
pub func Abs(x: float64) -> float64 | Computes the absolute value of x. |
pub func Abs(x: float32) -> float32 | Computes the absolute value of x at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | value 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.
| Overload | Summary |
|---|---|
pub func Max(a: float64, b: float64) -> float64 | Selects the larger of a and b. |
pub func Max(a: float32, b: float32) -> float32 | Selects the larger of a and b at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
a | float64 / float32 | first value to compare |
b | float64 / float32 | second 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.
| Overload | Summary |
|---|---|
pub func Min(a: float64, b: float64) -> float64 | Selects the smaller of a and b. |
pub func Min(a: float32, b: float32) -> float32 | Selects the smaller of a and b at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
a | float64 / float32 | first value to compare |
b | float64 / float32 | second value to compare |
Returns: the smaller non-NaN value, or a NaN when both arguments are NaNs