Fix formatting for negative numbers
This commit is contained in:
1 parent
1ea3590fd6
commit
79c0fceafe
1 file changed
+10
-2
@@ -129,7 +129,11 @@ func (n Numeric) String() string {
|
|||||||
|
|
||||||
exp = -exp
|
exp = -exp
|
||||||
for length <= exp {
|
for length <= exp {
|
||||||
bytes = append([]byte{byte('0')}, bytes...)
|
if n.Int.Int64() < 0 {
|
||||||
|
bytes = append([]byte{bytes[0], byte('0')}, bytes[1:]...)
|
||||||
|
} else {
|
||||||
|
bytes = append([]byte{byte('0')}, bytes...)
|
||||||
|
}
|
||||||
length++
|
length++
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +170,11 @@ func (n Numeric) MarshalJSON() ([]byte, error) {
|
|||||||
|
|
||||||
exp = -exp
|
exp = -exp
|
||||||
for length <= exp {
|
for length <= exp {
|
||||||
bytes = append([]byte{byte('0')}, bytes...)
|
if n.Int.Int64() < 0 {
|
||||||
|
bytes = append([]byte{bytes[0], byte('0')}, bytes[1:]...)
|
||||||
|
} else {
|
||||||
|
bytes = append([]byte{byte('0')}, bytes...)
|
||||||
|
}
|
||||||
length++
|
length++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user