All the integer functions in math/rand
generate non-negative numbers.
rand.Int() int // [0, MaxInt]
rand.Int31() int32 // [0, MaxInt32]
rand.Int31n(n int32) int32 // [0, n)
rand.Int63() int64 // [0, MaxInt64]
rand.Int63n(n int64) int64 // [0, n)
rand.Intn(n int) int // [0, n)
I would like to generate random numbers in the range [-m, n). In other words, I would like to generate a mix of positive and negative numbers.
question from:
https://stackoverflow.com/questions/23577091/generating-random-numbers-over-a-range-in-go 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…