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