pcg32

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Unlicense Imports: 4 Imported by: 0

Documentation

Overview

Package pcg32 implements the PCG-32 random number generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PCG32

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

PCG32 represents the state of a PCG-32 random number generator.

func New

func New() *PCG32

New creates a new PCG32 instance seeded with the current time.

func (*PCG32) Float32

func (p *PCG32) Float32() float32

Float32 generates a random float32 in the range [0.0, 1.0).

func (*PCG32) Float64

func (p *PCG32) Float64() float64

Float64 generates a random float64 in the range [0.0, 1.0).

func (*PCG32) Int

func (p *PCG32) Int(n int) int

Int generates a random integer in the range [0, n).

func (*PCG32) Int32

func (p *PCG32) Int32() int32

Int31 generates a random 31-bit signed integer.

func (*PCG32) Marshal

func (p *PCG32) Marshal() ([]byte, error)

Marshal returns the binary encoding of the current state of the random number generator.

func (*PCG32) Next

func (p *PCG32) Next() uint32

Next generates a random 32-bit unsigned integer.

func (*PCG32) Reset

func (p *PCG32) Reset()

Reset resets the state of the random number generator to the seed value.

func (*PCG32) Seed

func (p *PCG32) Seed(seed uint64)

Seed initializes the state of the random number generator with the given seed value.

func (*PCG32) State

func (p *PCG32) State() (uint64, uint64)

State returns the current state of the random number generator.

func (*PCG32) Unmarshal

func (p *PCG32) Unmarshal(data []byte) error

Unmarshal sets the state of the random number generator to the state represented by the input data.

Jump to

Keyboard shortcuts

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