bitops

package
v0.0.0-...-a34a5e8 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

bitops provides various bitwise utilities on uint64s which are not supported by math.bits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstBits

func FirstBits(n int, b uint64) uint64

FirstBits returns a uint64 consisting of the first n bits of b, filled up with 0s.

func LastBits

func LastBits(n int, b uint64) uint64

LastBits returns a uint64 consisting of the last n bits of b, filled up with 0s.

func LeadingOnesMask

func LeadingOnesMask(n int) uint64

LeadingOnesMask returns a bitmask where the first n bits are 1, the others are 0.

If n lies outside the valid range of [0, 64], it will be coerced to the nearest valid value.

func OnesMask

func OnesMask(leading, trailing int) uint64

OnesMask returns a bitmask where the first leading and last trailing bits are 1, while the bits between are 0.

If either of leading or trailing lie outside the valid range of [0, 64], they will be coerced to the nearest valid value.

func SingleOneMask

func SingleOneMask(idx int) uint64

SingleOneMask returns a bitmask where the single bit at position idx is 1, while all others are 0.

If idx is outside the valid range of [0, 63] it is coerced to the nearest valid value.

func TrailingOnesMask

func TrailingOnesMask(n int) uint64

TrailingOnesMask returns a bitmask where the last n bits are 1, the others are 0.

If n lies outside the valid range of [0, 64], it will be coerced to the nearest valid value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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