package main
import (
RR "crypto/rand"
"fmt"
"math"
"math/big"
"math/rand"
)
// 生成区间[-m, n]的安全随机数
func RangeRand(min, max int64) int64 {
if min > max {
panic("the min is greater than max!")
}
if min < 0 {
f64Min := math.Abs(float64(min))
i64Min := int64(f64Min)
result, _ := RR.Int(RR.Reader, big.NewInt(max+1+i64Min))
return result.Int64() - i64Min
} else {
result, _ := RR.Int(RR.Reader, big.NewInt(max-min+1))
return min + result.Int64()
}
}
func main() {
data1 := RangeRand(620, 625)
data2 := rand.Float32()
data := float32(data1) + data2
fmt.Printf("%.2f", data)
}