mathz

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxUint = ^uint(0)
	MaxInt  = int(^uint(0) >> 1)
)

Variables

This section is empty.

Functions

func Abs

func Abs(n int) int

Abs returns the absolute value of n.

func Binary

func Binary(n int) string

Binary returns the binary representation of n.

func BitCount

func BitCount[T typez.Integer](n T) int

BitCount returns the number of bits that are set in n.

func IsEven

func IsEven(n int) bool

IsEven returns true if n is even.

func IsPower2

func IsPower2(n uint) bool

IsPower2 returns true if n is a power of two.

func Max

func Max[T typez.Ordered](n ...T) T

Max returns the maximum value in a slice of numbers.

func MaxBitApprox

func MaxBitApprox(n int) int

MaxBitApprox return the highest bit of n that is 1

func Min

func Min[T typez.Ordered](n ...T) T

Min returns the minimum value in a slice of numbers.

func MinBitApprox

func MinBitApprox(n int) int

MinBitApprox return the lowest bit of n that is 1

func Pow

func Pow(x int, n uint) int

Pow returns x**n, the base-x exponential of n.

func Sum

func Sum[T typez.Number](n ...T) T

Sum returns the sum of a slice of numbers.

func Swap

func Swap(a, b *int)

Swap swaps the values of a and b.

Types

This section is empty.

Jump to

Keyboard shortcuts

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