Documentation
¶
Overview ¶
Package math provides some generic mathematical functions.
Index ¶
- func Abs[T constraints.Signed](x T) T
- func Cbrt[T numeric](x T) T
- func CopySign[T1, T2 constraints.Signed](x T1, y T2) T1
- func Dim[T numeric](x, y T) T
- func Max[T constraints.Ordered](x, y T) T
- func Min[T constraints.Ordered](x, y T) T
- func Pow[T numeric](x, y T) T
- func Pow10[T constraints.Integer](x T) T
- func Remainder[T numeric](x, y T) T
- func Round[T constraints.Float](x T) T
- func RoundInt[T constraints.Float](x T) int
- func RoundToEven[T constraints.Float](x T) T
- func RoundToEvenInt[T constraints.Float](x T) int
- func Sqrt[T constraints.Integer](x T) T
- func TryParseInt[T constraints.Integer](s string) option.Option[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopySign ¶
func CopySign[T1, T2 constraints.Signed](x T1, y T2) T1
CopySign returns a value with the magnitude of x and the sign of y.
func Pow10 ¶
func Pow10[T constraints.Integer](x T) T
Pow10 returns 10**n, the base-10 exponential of n.
func Remainder ¶
func Remainder[T numeric](x, y T) T
Remainder returns the IEEE 754 floating-point remainder of x/y.
func Round ¶
func Round[T constraints.Float](x T) T
Round returns the nearest integer as the float type of x, rounding half away from zero.
func RoundInt ¶
func RoundInt[T constraints.Float](x T) int
RoundInt returns the nearest integer as an int, rounding half away from zero.
func RoundToEven ¶
func RoundToEven[T constraints.Float](x T) T
RoundToEven returns the nearest integer as the float type of x, rounding ties to even.
func RoundToEvenInt ¶
func RoundToEvenInt[T constraints.Float](x T) int
RoundToEvenInt returns the nearest integer as an int, rounding ties to even.
func TryParseInt ¶
func TryParseInt[T constraints.Integer](s string) option.Option[T]
TryParseInt returns the integer parsed from s as an Option. If parsing fails, it returns None.
Types ¶
This section is empty.