Don't allocate room for more commas than necessary
closes #4
diff --git a/comma.go b/comma.go
index d032bfb..6ff6e90 100644
--- a/comma.go
+++ b/comma.go
@@ -15,7 +15,7 @@
v = 0 - v
}
- parts := []string{"", "", "", "", "", "", "", "", ""}
+ parts := []string{"", "", "", "", "", "", "", ""}
j := len(parts) - 1
for v > 999 {
diff --git a/comma_test.go b/comma_test.go
index 887a8e6..0d627ce 100644
--- a/comma_test.go
+++ b/comma_test.go
@@ -17,6 +17,8 @@
{"10,010,000", Comma(10010000), "10,010,000"},
{"10,001,000", Comma(10001000), "10,001,000"},
{"123,456,789", Comma(123456789), "123,456,789"},
+ {"maxint", Comma(9.223372e+18), "9,223,372,000,000,000,000"},
+ {"minint", Comma(-9.223372e+18), "-9,223,372,000,000,000,000"},
{"-123,456,789", Comma(-123456789), "-123,456,789"},
{"-10,100,000", Comma(-10100000), "-10,100,000"},
{"-10,010,000", Comma(-10010000), "-10,010,000"},