mirror of
https://github.com/MontFerret/ferret.git
synced 2025-07-15 01:25:00 +02:00
Minor updates to #578
This commit is contained in:
@ -46,9 +46,14 @@ func NumberLowerBoundary(input float64) float64 {
|
|||||||
return input / 2
|
return input / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
func Random(max float64, min float64) float64 {
|
func RandomDefault() float64 {
|
||||||
rand.Seed(time.Now().UnixNano())
|
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)
|
i := r * (max - min + 1)
|
||||||
out := math.Floor(i) + min
|
out := math.Floor(i) + min
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ package math
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"math/rand"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
"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 {
|
if len(args) == 0 {
|
||||||
rand.Seed(time.Now().UnixNano())
|
return values.NewFloat(core.RandomDefault()), nil
|
||||||
return values.NewFloat(rand.Float64()), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var max float64
|
var max float64
|
||||||
|
Reference in New Issue
Block a user