Fix formatting for negative numbers
This commit is contained in:
parent
1ea3590fd6
commit
79c0fceafe
@ -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++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user