bitutils

package
v0.28.16-only-dapper Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearBit added in v0.23.9

func ClearBit(b []byte, i int)

ClearBit clears the bit at index `i` in the byte slice `b`, i.e. it assigns value 0 to the bit. The function panics, if the byte slice is too short.

func MakeBitVector added in v0.23.9

func MakeBitVector(numberBits int) []byte

MakeBitVector allocates a byte slice of minimal size that can hold numberBits.

func MinimalByteSliceLength added in v0.26.1

func MinimalByteSliceLength(n int) int

MinimalByteSliceLength returns the minimal length of a byte slice that can store n bits.

func ReadBit added in v0.23.9

func ReadBit(b []byte, idx int) int

ReadBit returns the bit at index `idx` in the byte array `b` (big endian) The function panics, if the byte slice is too short.

func SetBit

func SetBit(b []byte, i int)

SetBit sets the bit at index `i` in the byte array `b`, i.e. it assigns value 1 to the bit. The function panics, if the byte slice is too short.

func WriteBit added in v0.23.9

func WriteBit(b []byte, i int, value int)

WriteBit assigns value `v` to the bit at index `i` in the byte array `b`. The function panics, if the byte slice is too short. We follow the common convention of converting between integer and boolean/bit values:

  • int value == 0 <=> false <=> bit 0
  • int value != 0 <=> true <=> bit 1

Types

This section is empty.

Jump to

Keyboard shortcuts

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