Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/locales.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/hy/hy.go
diff options
context:
space:
mode:
Diffstat (limited to 'hy/hy.go')
-rw-r--r--hy/hy.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/hy/hy.go b/hy/hy.go
index 2ea4e3b6..e86fc74e 100644
--- a/hy/hy.go
+++ b/hy/hy.go
@@ -95,8 +95,7 @@ func (hy *hy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64)
// avoid allocations; otherwise just cast as string.
func (hy *hy) FmtNumber(num float64, v uint64) []byte {
- s := strconv.FormatFloat(num, 'f', int(v), 64)
-
+ s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
l := len(s) + len(hy.decimal)
b := make([]byte, 0, l)
@@ -104,22 +103,21 @@ func (hy *hy) FmtNumber(num float64, v uint64) []byte {
for i := len(s) - 1; i >= 0; i-- {
if s[i] == '.' {
-
- for j := len(hy.decimal) - 1; j >= 0; j-- {
- b = append(b, hy.decimal[j])
- }
-
+ b = append(b, hy.decimal[0])
continue
}
b = append(b, s[i])
}
+ if num < 0 {
+ b = append(b, hy.minus[0])
+ }
+
// reverse
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i]
}
return b
-
}