mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-29 06:01:21 +00:00
add Float64() and RandFloat64().
This commit is contained in:
parent
ee67e34519
commit
3375dac049
@ -113,6 +113,10 @@ func RandFloat32() float32 {
|
|||||||
return grand.Float32()
|
return grand.Float32()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RandFloat64() float64 {
|
||||||
|
return grand.Float64()
|
||||||
|
}
|
||||||
|
|
||||||
func RandTime() time.Time {
|
func RandTime() time.Time {
|
||||||
return grand.Time()
|
return grand.Time()
|
||||||
}
|
}
|
||||||
@ -272,6 +276,14 @@ func (r *Rand) Float32() float32 {
|
|||||||
return f32
|
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.
|
// It is not safe for cryptographic usage.
|
||||||
func (r *Rand) Time() time.Time {
|
func (r *Rand) Time() time.Time {
|
||||||
return time.Unix(int64(r.Uint64Exp()), 0)
|
return time.Unix(int64(r.Uint64Exp()), 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user