horse: fix TenThousandths formatting
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package horse
|
||||
|
||||
import "strconv"
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type SkillID int32
|
||||
|
||||
@@ -9,11 +13,14 @@ type TenThousandths int32
|
||||
func (x TenThousandths) String() string {
|
||||
b := make([]byte, 0, 12)
|
||||
b = strconv.AppendInt(b, int64(x/1e4), 10)
|
||||
b = append(b, '.')
|
||||
if x < 0 {
|
||||
x = -x
|
||||
if x%1e4 != 0 {
|
||||
if x < 0 {
|
||||
x = -x
|
||||
}
|
||||
b = append(b, '.')
|
||||
b = fmt.Appendf(b, "%04d", x%1e4)
|
||||
b = bytes.TrimRight(b, "0")
|
||||
}
|
||||
b = strconv.AppendInt(b, int64(x%1e4), 10)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user