mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-04 10:35:08 +02:00
Minor updates to #578
This commit is contained in:
parent
f0097e984e
commit
cd1b1cf5c7
@ -46,9 +46,14 @@ func NumberLowerBoundary(input float64) float64 {
|
||||
return input / 2
|
||||
}
|
||||
|
||||
func Random(max float64, min float64) float64 {
|
||||
func RandomDefault() float64 {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
r := rand.Float64()
|
||||
|
||||
return rand.Float64()
|
||||
}
|
||||
|
||||
func Random(max float64, min float64) float64 {
|
||||
r := RandomDefault()
|
||||
i := r * (max - min + 1)
|
||||
out := math.Floor(i) + min
|
||||
|
||||
|
@ -2,8 +2,6 @@ package math
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||
@ -21,8 +19,7 @@ func Rand(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
return values.NewFloat(rand.Float64()), nil
|
||||
return values.NewFloat(core.RandomDefault()), nil
|
||||
}
|
||||
|
||||
var max float64
|
||||
|
Loading…
Reference in New Issue
Block a user