bits

package
v0.0.0-...-451def6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package bits provides bit manipulation functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cycle

func Cycle(currentVal, rangeLimit uint64) uint64

Cycle uses a Linear Congruential Generator (LCG) and cycle walking to produce a pseudo-random sequence in [0, rangeLimit)

func Mix

func Mix(x uint64, bitLen int) uint64

Mix shuffles x with b bits (bijective) This ensures that every input maps to exactly one unique output.

func NextPow2

func NextPow2(n uint) int

NextPow2 returns the smallest power of 2 >= n

func Shuffle16

func Shuffle16(n uint16) uint16

func Shuffle32

func Shuffle32(n uint32) uint32

func TrailingOnes

func TrailingOnes(x int) int

TrailingOnes returns the number of trailing one bits in x

Types

type Gen

type Gen struct {
	// contains filtered or unexported fields
}

func NewGen

func NewGen(rnd *rand.Rand, rangeLimit uint64) *Gen

func (*Gen) Next

func (g *Gen) Next() uint64

Jump to

Keyboard shortcuts

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