SetString sets d to s. Any non-standard NaN values are converted to a normal NaN. Any negative zero is converted to positive.
(s string)
| 918 | // SetString sets d to s. Any non-standard NaN values are converted to a |
| 919 | // normal NaN. Any negative zero is converted to positive. |
| 920 | func (d *DDecimal) SetString(s string) error { |
| 921 | // ExactCtx should be able to handle any decimal, but if there is any rounding |
| 922 | // or other inexact conversion, it will result in an error. |
| 923 | //_, res, err := HighPrecisionCtx.SetString(&d.Decimal, s) |
| 924 | _, res, err := ExactCtx.SetString(&d.Decimal, s) |
| 925 | if res != 0 || err != nil { |
| 926 | return makeParseError(s, types.Decimal, nil) |
| 927 | } |
| 928 | switch d.Form { |
| 929 | case apd.NaNSignaling: |
| 930 | d.Form = apd.NaN |
| 931 | d.Negative = false |
| 932 | case apd.NaN: |
| 933 | d.Negative = false |
| 934 | case apd.Finite: |
| 935 | if d.IsZero() && d.Negative { |
| 936 | d.Negative = false |
| 937 | } |
| 938 | } |
| 939 | return nil |
| 940 | } |
| 941 | |
| 942 | // ResolvedType implements the TypedExpr interface. |
| 943 | func (*DDecimal) ResolvedType() *types.T { |
no test coverage detected