mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
fix formatString
This commit is contained in:
parent
99b025dd5c
commit
9c45e6693f
|
@ -111,8 +111,8 @@ func (v Value) FormatPercentage(prec int) string {
|
|||
if v == 0 {
|
||||
return "0"
|
||||
}
|
||||
result := strconv.FormatFloat(float64(v)/DefaultPow*100., 'f', prec+1, 64)
|
||||
return result[:len(result)-1] + "%"
|
||||
result := strconv.FormatFloat(float64(v)/DefaultPow*100., 'f', prec, 64)
|
||||
return result + "%"
|
||||
}
|
||||
|
||||
func (v Value) SignedPercentage() string {
|
||||
|
|
|
@ -273,7 +273,11 @@ func (dn Value) FormatString(prec int) string {
|
|||
return sign + digits[:dec] + "." + digits[dec:min(dec+prec, nd)] + strings.Repeat("0", max(0, min(dec+prec, nd)-dec-prec))
|
||||
} else if 0 < dn.exp && dn.exp <= digitsMax {
|
||||
// decimal to the right
|
||||
if prec > 0 {
|
||||
return sign + digits + strings.Repeat("0", e) + "." + strings.Repeat("0", prec)
|
||||
} else {
|
||||
return sign + digits + strings.Repeat("0", e)
|
||||
}
|
||||
} else {
|
||||
// scientific notation
|
||||
after := ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user