}
}
+ exp := math.Pow(10.0, float64(prec))
+ r := math.Round(n*exp) / exp
+
// Logic from MIT Licensed github.com/go-playground/locales/
// Original Copyright (c) 2016 Go Playground
- s := strconv.FormatFloat(math.Abs(n), 'f', prec, 64)
+ s := strconv.FormatFloat(math.Abs(r), 'f', prec, 64)
L := len(s) + 2 + len(s[:len(s)-1-prec])/3
var count int
{0, 12345.6789, "- . ,", "", "12,346"},
{11, -12345.6789, "- . ,", "", "-12,345.67890000000"},
+ {2, 927.675, "- .", "", "927.68"},
+ {2, 1927.675, "- .", "", "1927.68"},
+ {2, 2927.675, "- .", "", "2927.68"},
+
{3, -12345.6789, "- ,", "", "-12345,679"},
{6, -12345.6789, "- , .", "", "-12.345,678900"},