numbers

package
v0.0.0-...-58421e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const Float32MaxInt = 1 << 24

Float32MaxInt represents the maximum integer which can be represented using a float32 value without loss of precision

View Source
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL