Skip to content

Commit

Permalink
修改FloatFromStringDontRound方法
Browse files Browse the repository at this point in the history
  • Loading branch information
idoall committed Aug 26, 2021
1 parent 866f2ac commit 3cd32be
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion commonutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ func FloatFromString(raw interface{}) (float64, error) {
func FloatFromStringDontRound(num float64, exp int) (result float64, err error) {
n := strconv.FormatFloat(num, 'f', -1, 32)
newn := strings.Split(n, ".")

if exp < 0 {
exp = int(math.Abs(float64(exp)))
}
if len(newn) == 1 {
result, err = strconv.ParseFloat(newn[0], 64)
} else if len(newn[1]) >= exp {
Expand Down

0 comments on commit 3cd32be

Please sign in to comment.