package commonus import ( "fmt" "math/rand" "strconv" "time" "github.com/shopspring/decimal" ) //float精度运算 func FloatAccuracyOperation(floatVal float64) (res float64) { num, _ := strconv.ParseFloat(fmt.Sprintf("%.8f", floatVal), 64) fmt.Println(num) decimalValue := decimal.NewFromFloat(num) decimalValue = decimalValue.Mul(decimal.NewFromInt(100)) res, _ = decimalValue.Float64() return } //获取编号 func GetFileNumber() (num int64) { randVal := rand.Intn(1000) timeVal := time.Now().Unix() num, _ = strconv.ParseInt(strconv.FormatInt(timeVal, 10)+strconv.Itoa(randVal), 10, 64) return }