integer

package
v2.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOverflow = errors.New("integer overflow")

Functions

func AlignPowTwo

func AlignPowTwo(x uint) uint

AlignPowTwo returns the next 2^n >= x, for some integer n.

If x > 2^(bits.UintSize - 1), this function panics with ErrOverflow.

func AlignPowTwo32

func AlignPowTwo32(x uint32) uint32

AlignPowTwo32 returns the next 2^n >= x, for some integer n.

If x > 2^31, this function panics with ErrOverflow.

func AlignPowTwo64

func AlignPowTwo64(x uint64) uint64

AlignPowTwo64 returns the next 2^n >= x, for some integer n.

If x > 2^63, this function panics with ErrOverflow.

func IsPowTwo

func IsPowTwo(x uint) bool

IsPowTwo returns true iff x == 2^n for some integer n >= 0.

func IsPowTwo32

func IsPowTwo32(x uint32) bool

IsPowTwo32 returns true iff x == 2^n for some integer n >= 0.

func IsPowTwo64

func IsPowTwo64(x uint64) bool

IsPowTwo64 returns true iff x == 2^n for some integer n >= 0.

func NextPowTwo

func NextPowTwo(x uint) uint

NextPowTwo returns the next 2^n > x, for some integer n.

If x >= 2^(bits.UintSize - 1), this function panics with ErrOverflow.

func NextPowTwo32

func NextPowTwo32(x uint32) uint32

NextPowTwo32 returns the next 2^n > x, for some integer n.

If x >= 2^31, this function panics with ErrOverflow.

func NextPowTwo64

func NextPowTwo64(x uint64) uint64

NextPowTwo64 returns the next 2^n > x, for some integer n.

If x >= 2^63, this function panics with ErrOverflow.

func Pow

func Pow[T constraints.Integer](x, n T) T

Pow implements x^n for integers.

Note that this function is not robust in the event of integer overflow.

Types

This section is empty.

Jump to

Keyboard shortcuts

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