Documentation
¶
Index ¶
- Constants
- func GCD[T constraints.Integer](a, b T) T
- func IntAbs[T constraints.Integer](x T) T
- func IntAbsDiff[T constraints.Integer](x, y T) T
- func IntMod[T constraints.Integer](a, b T) T
- func IntPow[T constraints.Integer](base, exp T) T
- func IntRoundedDiv[T constraints.Integer](a, b T) T
- func IntSign[T constraints.Integer](x T) int
- func LCM[T constraints.Integer](a, b T) T
Constants ¶
const Float32MaxInt = 1 << 24
Float32MaxInt represents the maximum integer which can be represented using a float32 value without loss of precision
const Float64MaxInt = 1 << 53
Float64MaxInt represents the maximum integer which can be represented using a float64 value without loss of precision
Variables ¶
This section is empty.
Functions ¶
func GCD ¶
func GCD[T constraints.Integer](a, b T) T
GCD returns the greatest common divisor of two integers using the Euclidean algorithm, e.g. GCD(12, 18) = 6
func IntAbs ¶
func IntAbs[T constraints.Integer](x T) T
func IntAbsDiff ¶
func IntAbsDiff[T constraints.Integer](x, y T) T
func IntMod ¶
func IntMod[T constraints.Integer](a, b T) T
IntMod returns the smallest non-negative remainder (e.g. IntMod(-1, 5) = 4) For non-negative a values this is equivalent to the % operator
func IntPow ¶
func IntPow[T constraints.Integer](base, exp T) T
IntPow computes base**exp using exponentiation by squaring
func IntRoundedDiv ¶
func IntRoundedDiv[T constraints.Integer](a, b T) T
IntRoundedDiv divides two integers rounding to the nearest integer, rounding half away from zero. This should be equivalent to
math.Round(float64(a) / float64(b))
which uses the same half rounding method
func IntSign ¶
func IntSign[T constraints.Integer](x T) int
func LCM ¶
func LCM[T constraints.Integer](a, b T) T
LCM returns the least common multiple of two integers, e.g. LCM(12, 18) = 36
Types ¶
This section is empty.