Documentation ¶
Index ¶
- func AbsInt[N types.SignedInteger](n N) N
- func Difference[N types.Integer](a, b N) N
- func Even[N types.Integer](x N) bool
- func GCD[N types.UnsignedInteger](a, b N) N
- func LCM[N types.UnsignedInteger](a, b N) N
- func Max[N types.Integer](x, y N) N
- func MaxN[N types.Integer](x ...N) N
- func Min[N types.Integer](x, y N) N
- func MinN[N types.Integer](x ...N) N
- func Odd[N types.Integer](x N) bool
- func PowUint[U types.UnsignedInteger](base, power U) U
- func Sign[N types.Integer](x N) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsInt ¶
func AbsInt[N types.SignedInteger](n N) N
AbsInt determines the absolute value of provided integer.
func Difference ¶
Difference computes an absolute value that's the difference between `a` and `b`.
func GCD ¶
func GCD[N types.UnsignedInteger](a, b N) N
GCD is a unoptimized, inefficient version of the Greatest Common Divisor.
Using Euclidian algorithm, following [1]: `gcd(a, b) == gcd(b, a mod b)` for `a > b`. Perform repeatedly until `gcd(x, 0)`, at which point `x` is greatest common divisor for `gcd(a,b)`.
[1]: <https://en.wikipedia.org/wiki/Greatest_common_divisor>
func LCM ¶
func LCM[N types.UnsignedInteger](a, b N) N
LCM is a unoptimized version of the Least/Lowest Common Multiple.
Using the Greatest Common Divisor, following [1]: `lcm(a,b) = |ab| / gcd(a,b)`
func MaxN ¶
MaxN returns the maximum of vararg provided number of values. At least one value must be provided or the function will panic.
func PowUint ¶
func PowUint[U types.UnsignedInteger](base, power U) U
PowUint calculates a power of a given base for an arbitrary base value.
NOTE: this function is not optimized for very large calculations and care should be taken to choose a data-type with sufficient space to contain the result.
Types ¶
This section is empty.