28 lines
511 B
Go
28 lines
511 B
Go
package rand
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand/v2"
|
|
"time"
|
|
)
|
|
|
|
func Rand() {
|
|
dur := rand.N(5 * time.Second)
|
|
fmt.Println(dur)
|
|
|
|
fmt.Println("Ints")
|
|
fmt.Print(rand.IntN(5), " ")
|
|
fmt.Print(rand.IntN(5), " ")
|
|
fmt.Print(rand.IntN(5), " ")
|
|
fmt.Println()
|
|
|
|
fmt.Println("Floats")
|
|
fmt.Println(rand.Float64())
|
|
fmt.Println("b/w 5 and 10:", rand.Float64()*5+5)
|
|
|
|
fmt.Println("Custom seed")
|
|
pcg := rand.NewPCG(1024, 10)
|
|
myRand := rand.New(pcg)
|
|
fmt.Printf("%d %d %d\n", myRand.IntN(5), myRand.IntN(5), myRand.IntN(5))
|
|
}
|