Documentation ¶
Overview ¶
Package num implements various utility functions regarding numeric types.
Index ¶
- func Abs[T Real](x T) T
- func ByteSizeT[T Integer]() int
- func IsPowerOfTwo[T Integer](x T) bool
- func IsSigned[T Real]() bool
- func Log2[T Integer](x T) int
- func Max[T Real](x, y T) T
- func MaxN[T Real](x ...T) T
- func MaxT[T Integer]() uint64
- func Min[T Real](x, y T) T
- func MinN[T Real](x ...T) T
- func MinT[T Integer]() int64
- func RoundRatio[T Integer](x, y T) T
- func RoundRatioBits[T Integer](x T, bits int) T
- func SizeT[T Integer]() int
- func Sqrt[T Integer](x T) T
- type Integer
- type Number
- type Real
- type Unsigned
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteSizeT ¶ added in v0.3.0
ByteSizeT returns the bytes required to express value of type T in int.
func IsPowerOfTwo ¶
IsPowerOfTwo returns whether x is a power of two. If x < 0, it always returns false.
func MaxN ¶
func MaxN[T Real](x ...T) T
MaxN returns the largest number of x. If x is empty, it returns the zero value of T.
func MinN ¶
func MinN[T Real](x ...T) T
MinN returns the smallest number of x. If x is empty, it returns the zero value of T.
func RoundRatioBits ¶
RoundRatioBits is a bit-optimzed version of RoundRatio: it returns round(x/2^bits).
If bits <= 0, it panics.
Types ¶
type Number ¶
type Number interface { Real | complex64 | complex128 }
Number represents Integer, Float, and Complex type.
Click to show internal directories.
Click to hide internal directories.