diff --git a/horse/skill.go b/horse/skill.go index 447fbb0..c6323cb 100644 --- a/horse/skill.go +++ b/horse/skill.go @@ -12,11 +12,12 @@ type TenThousandths int32 func (x TenThousandths) String() string { b := make([]byte, 0, 12) + if x < 0 { + x = -x + b = append(b, '-') + } b = strconv.AppendInt(b, int64(x/1e4), 10) if x%1e4 != 0 { - if x < 0 { - x = -x - } b = append(b, '.') b = fmt.Appendf(b, "%04d", x%1e4) b = bytes.TrimRight(b, "0") diff --git a/horse/skill_test.go b/horse/skill_test.go index 61129d3..4611821 100644 --- a/horse/skill_test.go +++ b/horse/skill_test.go @@ -40,6 +40,8 @@ func TestTenThousandthsString(t *testing.T) { want string }{ {0, "0"}, + {500, "0.05"}, + {-500, "-0.05"}, {10000, "1"}, {-10000, "-1"}, {15000, "1.5"},