mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 18:26:16 +00:00
修复:优化创建交易流程代码,将金额修改为保留3位小数点
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package math
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// MustParsePrecFloat64 按小数位截取float
|
||||
func MustParsePrecFloat64(value float64, prec int) float64 {
|
||||
format := fmt.Sprintf("%%.%df", prec)
|
||||
v, err := strconv.ParseFloat(fmt.Sprintf(format, value), 64)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return v
|
||||
}
|
||||
Reference in New Issue
Block a user