horse: fix TenThousandths formatting

This commit is contained in:
2026-01-16 20:47:01 -05:00
parent b0c555f547
commit dc2094bd50
2 changed files with 34 additions and 5 deletions

View File

@@ -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)
}