From 3375dac049d2e7c597b29485d294b6f30798b4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Tue, 3 Apr 2018 14:09:50 +0200 Subject: [PATCH] add Float64() and RandFloat64(). --- common/random.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/random.go b/common/random.go index af531992e..b767e3589 100644 --- a/common/random.go +++ b/common/random.go @@ -113,6 +113,10 @@ func RandFloat32() float32 { return grand.Float32() } +func RandFloat64() float64 { + return grand.Float64() +} + func RandTime() time.Time { return grand.Time() } @@ -272,6 +276,14 @@ func (r *Rand) Float32() float32 { return f32 } +// It is not safe for cryptographic usage. +func (r *Rand) Float64() float64 { + r.Lock() + f64 := r.rand.Float64() + r.Unlock() + return f64 +} + // It is not safe for cryptographic usage. func (r *Rand) Time() time.Time { return time.Unix(int64(r.Uint64Exp()), 0)