bitutil

package
v0.0.0-...-07f142d Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BitMask        = [8]byte{1, 2, 4, 8, 16, 32, 64, 128}
	FlippedBitMask = [8]byte{254, 253, 251, 247, 239, 223, 191, 127}
)

Functions

func BitIsNotSet

func BitIsNotSet(buf []byte, i int) bool

BitIsNotSet returns true if the bit at index i in buf is not set (0).

func BitIsSet

func BitIsSet(buf []byte, i int) bool

BitIsSet returns true if the bit at index i in buf is set (1).

func CeilByte

func CeilByte(size int) int

CeilByte rounds size to the next multiple of 8.

func ClearBit

func ClearBit(buf []byte, i int)

ClearBit sets the bit at index i in buf to 0.

func CountSetBits

func CountSetBits(buf []byte, n int) int

CountSetBits counts the number of 1's in buf up to n bits.

func NextPowerOf2

func NextPowerOf2(x int) int

NextPowerOf2 rounds x to the next power of two.

func SetBit

func SetBit(buf []byte, i int)

SetBit sets the bit at index i in buf to 1.

func SetBitTo

func SetBitTo(buf []byte, i int, val bool)

SetBitTo sets the bit at index i in buf to val.

Types

This section is empty.

Jump to

Keyboard shortcuts

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