Skip to content

Commit 20a3031

Browse files
committed
rand: add methods to allow greater control over PCGSource
For golang/go#49934.
1 parent 053ad81 commit 20a3031

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

rand/rng.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ func (pcg *PCGSource) Uint64() uint64 {
5858
return bits.RotateLeft64(pcg.high^pcg.low, -int(pcg.high>>58))
5959
}
6060

61+
// Seed64 sets both the high and low bits of the generator state to the provided values.
62+
func (pcg *PCGSource) Seed64(high, low uint64) {
63+
pcg.high = high
64+
pcg.low = low
65+
}
66+
67+
// PCG returns the high and low bits of the generator state.
68+
func (pcg *PCGSource) PCG() (high, low uint64) {
69+
return pcg.high, pcg.low
70+
}
71+
6172
func (pcg *PCGSource) add() {
6273
var carry uint64
6374
pcg.low, carry = bits.Add64(pcg.low, incLow, 0)

0 commit comments

Comments
 (0)