// Get a random uint64 value evenly distributed in [0,bounds)
322340
func (pcg *Pcg128x64) NextN(bounds uint64) uint64 {
  threshold := (0 - bounds) % bounds
  for {
    result := pcg.Next()
    if result >= threshold {
      return result % bounds;
    }
  }
}
1042693
func RandomValuesWithMax(count int, max float64) []float64 {
	return Seq{NewRandom().WithMax(max).WithLen(count)}.Array()
}
1026986
func Int64Value(val string) (*wrappers.Int64Value, error) {
	parsedVal, err := Int64(val)
	return &wrappers.Int64Value{Value: parsedVal}, err
}
996711
func (s *Session) Uint64(key string) uint64 {
	s.RLock()
	defer s.RUnlock()

	v, ok := s.data[key]
	if !ok {
		return 0
	}

	value, ok := v.(uint64)
	if !ok {
		return 0
	}
	return value
}
1196901
func randInt(from, to int) int {
	return prng.Intn(to+1-from) + from
}
105184
func (r Row) GetUint64(colIdx int) uint64 {
	col := r.c.columns[colIdx]
	return *(*uint64)(unsafe.Pointer(&col.data[r.idx*8]))
}
776220
func (lr *LockedRand) Uint32() (n uint32) {
	lr.lk.Lock()
	n = lr.r.Uint32()
	lr.lk.Unlock()
	return
}
22247
func (r *Random) GetValue(_ int) float64 {
	if r.min != nil && r.max != nil {
		var delta float64

		if *r.max > *r.min {
			delta = *r.max - *r.min
		} else {
			delta = *r.min - *r.max
		}

		return *r.min + (r.rnd.Float64() * delta)
	} else if r.max != nil {
		return r.rnd.Float64() * *r.max
	} else if r.min != nil {
		return *r.min + (r.rnd.Float64())
	}
	return r.rnd.Float64()
}
39351
func readRandomUint32() uint32 {
	var b [4]byte
	_, err := io.ReadFull(rand.Reader, b[:])
	if err != nil {
		panic(fmt.Errorf("cannot read random object id: %v", err))
	}
	return uint32((uint32(b[0]) << 0) | (uint32(b[1]) << 8) | (uint32(b[2]) << 16) | (uint32(b[3]) << 24))
}
233644
func (h Hash) Uint64(key string) (uint64, error) {
	if value, ok := h[key]; ok {
		return value.Uint64()
	}
	return 0, errors.New(ErrInvalidKey, errorMessages, key)
}
925826
func (p *packetNumberGenerator) getRandomNumber() uint16 {
	b := make([]byte, 2)
	rand.Read(b) // ignore the error here

	num := uint16(b[0])<<8 + uint16(b[1])
	return num
}
1341649
func GenerateRandomBytes(n int) ([]byte, error) {
	b := make([]byte, n)
	_, err := rand.Read(b)

	if err != nil {
		zap.L().Debug("GenerateRandomBytes failed", zap.Error(err))
		return nil, err
	}

	s := base64.StdEncoding.EncodeToString(b)

	return []byte(s[:n]), nil
}
1027779
func RandN32(n int) []uint32 {
	b := make([]byte, 4*n)
	if _, err := rand.Read(b); err != nil {
		panic("unable to get random numbers: " + err.Error())
	}
	r := make([]uint32, n)
	for i := range r {
		r[i] = binary.LittleEndian.Uint32(b[4*i : (4*i + 4)])
	}
	return r
}
160403
func (b *NullByteSizeInMb) ParseUint64Value(val *uint64) {
	if val == nil {
		b.IsSet = false
		b.Value = 0
		return
	}

	b.Value = *val
	b.IsSet = true
}
801402
func (c *Random) Get(base int64) bgzf.Block {
	c.mu.Lock()
	defer c.mu.Unlock()

	b, ok := c.table[base]
	if !ok {
		return nil
	}
	delete(c.table, base)
	return b
}
168494
func (u *Ugen) Rand() Input {
	return unaryOpRand(u.Rate, u, u.NumOutputs)
}
653844
func (u Uint64) Get() (uint64, error) {
	if !u.Present() {
		var zero uint64
		return zero, errors.New("value not present")
	}
	return *u.value, nil
}