Documentation ¶
Index ¶
- func Abs[V constraints.Signed](n V) V
- func Binomial[V constraints.Unsigned](n, k V) (uint64, bool)
- func CeilLog10[V constraints.Unsigned](u V) V
- func CeilLog2[V constraints.Unsigned](u V) V
- func FloorLog10[V constraints.Unsigned](u V) V
- func FloorLog2[V constraints.Unsigned](u V) V
- func Len[V constraints.Unsigned](u V) V
- func Pow[V constraints.Unsigned](m, n V) V
- func PowX[V constraints.Unsigned](m, n V) (pow uint64, overflowed bool)
- func Sqrt[V constraints.Unsigned](n V) V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[V constraints.Signed](n V) V
Abs(n) computes the absolute value of n, without branching.
func Binomial ¶
func Binomial[V constraints.Unsigned](n, k V) (uint64, bool)
Binomial(n, k) == ‹(n k), false›. Unless the result overflows uint64, in which case it returns ‹0, true›.
func CeilLog10 ¶
func CeilLog10[V constraints.Unsigned](u V) V
CeilLog10(u) returns ⌈log₁₀u⌉.
If u is 0, anything might happen 🤷
func CeilLog2 ¶
func CeilLog2[V constraints.Unsigned](u V) V
CeilLog2(u) returns ⌈log₂u⌉.
If u is 0, anything might happen 🤷
func FloorLog10 ¶
func FloorLog10[V constraints.Unsigned](u V) V
FloorLog10(u) returns ⌊log₁₀u⌋
If u is 0, anything might happen 🤷
func FloorLog2 ¶
func FloorLog2[V constraints.Unsigned](u V) V
FloorLog10(u) returns ⌊log₂u⌋
If u is 0, anything might happen 🤷
func Len ¶
func Len[V constraints.Unsigned](u V) V
Len(u) returns the length of the base-10 string of u.
func PowX ¶
func PowX[V constraints.Unsigned](m, n V) (pow uint64, overflowed bool)
PowX(m, n) == ‹mⁿ, false› as long as it fits in a uint64. As soon as it overflows it returns ‹0, true›.
func Sqrt ¶
func Sqrt[V constraints.Unsigned](n V) V
Sqrt(u) returns √u
NOTE the current implementation uses floating point as that is implemented in hardware in most places (see SqrtI and associated benchmarks in the tests). This might change if somebody points me to a faster version.
Types ¶
This section is empty.