Compare commits
1 Commits
94d31e829e
...
5560c59614
Author | SHA1 | Date | |
---|---|---|---|
5560c59614 |
@ -2,7 +2,6 @@ package wat
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -122,11 +121,11 @@ func (g *WatGame) help() string {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *WatGame) RandInt(max int64) (uint64, error) {
|
func (g *WatGame) RandInt(maxx int64) (uint64, error) {
|
||||||
bi := big.NewInt(max)
|
bi := big.NewInt(maxx)
|
||||||
// prevent panic of rand.Int on big numbers
|
// prevent panic of rand.Int on big numbers
|
||||||
if bi.BitLen() < 2 {
|
if bi.BitLen() < 2 {
|
||||||
return 0, errors.New("overflow")
|
return 0, fmt.Errorf("overflow, got %d", bi)
|
||||||
}
|
}
|
||||||
i, err := rand.Int(rand.Reader, bi)
|
i, err := rand.Int(rand.Reader, bi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user