diff --git a/postgres/numeric/numeric.go b/postgres/numeric/numeric.go index 73fdb16..8d0cc5e 100644 --- a/postgres/numeric/numeric.go +++ b/postgres/numeric/numeric.go @@ -129,7 +129,11 @@ func (n Numeric) String() string { exp = -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++ } @@ -166,7 +170,11 @@ func (n Numeric) MarshalJSON() ([]byte, error) { exp = -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++ }