Add infinity support for Numeric Text Encode/Decode
This commit is contained in:
committed by
Jack Christensen
parent
001b3166b9
commit
8890a746d7
+12
@@ -431,6 +431,12 @@ func (dst *Numeric) DecodeText(ci *ConnInfo, src []byte) error {
|
|||||||
if string(src) == "NaN" {
|
if string(src) == "NaN" {
|
||||||
*dst = Numeric{Status: Present, NaN: true}
|
*dst = Numeric{Status: Present, NaN: true}
|
||||||
return nil
|
return nil
|
||||||
|
} else if string(src) == "Infinity" {
|
||||||
|
*dst = Numeric{Status: Present, InfinityModifier: Infinity}
|
||||||
|
return nil
|
||||||
|
} else if string(src) == "-Infinity" {
|
||||||
|
*dst = Numeric{Status: Present, InfinityModifier: NegativeInfinity}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
num, exp, err := parseNumericString(string(src))
|
num, exp, err := parseNumericString(string(src))
|
||||||
@@ -597,6 +603,12 @@ func (src Numeric) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
|
|||||||
if src.NaN {
|
if src.NaN {
|
||||||
buf = append(buf, "NaN"...)
|
buf = append(buf, "NaN"...)
|
||||||
return buf, nil
|
return buf, nil
|
||||||
|
} else if src.InfinityModifier == Infinity {
|
||||||
|
buf = append(buf, "Infinity"...)
|
||||||
|
return buf, nil
|
||||||
|
} else if src.InfinityModifier == NegativeInfinity {
|
||||||
|
buf = append(buf, "-Infinity"...)
|
||||||
|
return buf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = append(buf, src.Int.String()...)
|
buf = append(buf, src.Int.String()...)
|
||||||
|
|||||||
Reference in New Issue
Block a user