We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d11f4e1 + f95ad66 commit e48e3f4Copy full SHA for e48e3f4
pkg/utils/view.go
@@ -2,6 +2,7 @@ package utils
2
3
import (
4
"fmt"
5
+ "math"
6
"strings"
7
)
8
@@ -81,6 +82,11 @@ func SizeByteToGB(v *int32) string {
81
82
}
83
84
func FormatFloat(number float64) string {
85
+ isNegative := false
86
+ if number < 0 {
87
+ isNegative = true
88
+ number = math.Abs(number)
89
+ }
90
parts := strings.Split(fmt.Sprintf("%.2f", number), ".")
91
integerPart := parts[0]
92
decimalPart := parts[1]
@@ -92,6 +98,9 @@ func FormatFloat(number float64) string {
98
93
99
result = append(result, rune(digit))
94
100
95
-
96
- return fmt.Sprintf("%s.%s", string(result), decimalPart)
101
+ if isNegative {
102
+ return fmt.Sprintf("-%s.%s", string(result), decimalPart)
103
+ } else {
104
+ return fmt.Sprintf("%s.%s", string(result), decimalPart)
105
97
106
0 commit comments