bits

package
v0.0.0-...-e4c45ee Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0, MIT Imports: 0 Imported by: 0

Documentation

Overview

Package bits includes all bit related types and operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignDown

func AlignDown(length int, align uint) int

AlignDown rounds a length down to an alignment. align must be a power of 2.

func AlignUp

func AlignUp(length int, align uint) int

AlignUp rounds a length up to an alignment. align must be a power of 2.

func ForEachSetBit64

func ForEachSetBit64(x uint64, f func(i int))

ForEachSetBit64 calls f once for each set bit in x, with argument i equal to the set bit's index.

func IsAnyOn32

func IsAnyOn32(mask, bits uint32) bool

IsAnyOn returns true if *any* bit set in 'bits' is set in 'mask'.

func IsAnyOn64

func IsAnyOn64(mask, bits uint64) bool

IsAnyOn returns true if *any* bit set in 'bits' is set in 'mask'.

func IsOn32

func IsOn32(mask, bits uint32) bool

IsOn returns true if *all* bits set in 'bits' are set in 'mask'.

func IsOn64

func IsOn64(mask, bits uint64) bool

IsOn returns true if *all* bits set in 'bits' are set in 'mask'.

func IsPowerOfTwo32

func IsPowerOfTwo32(v uint32) bool

IsPowerOfTwo returns true if v is power of 2.

func IsPowerOfTwo64

func IsPowerOfTwo64(v uint64) bool

IsPowerOfTwo returns true if v is power of 2.

func Mask32

func Mask32(is ...int) uint32

Mask returns a T with all of the given bits set.

func Mask64

func Mask64(is ...int) uint64

Mask returns a T with all of the given bits set.

func MaskOf32

func MaskOf32(i int) uint32

MaskOf is like Mask, but sets only a single bit (more efficiently).

func MaskOf64

func MaskOf64(i int) uint64

MaskOf is like Mask, but sets only a single bit (more efficiently).

func MostSignificantOne64

func MostSignificantOne64(x uint64) int

MostSignificantOne64 returns the index of the most significant 1 bit in x. If x is 0, MostSignificantOne64 returns 64.

func TrailingZeros64

func TrailingZeros64(x uint64) int

TrailingZeros64 returns the number of bits before the least significant 1 bit in x; in other words, it returns the index of the least significant 1 bit in x. If x is 0, TrailingZeros64 returns 64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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