Merge pull request #137 from lantw44/master

Fix decoding of .0
This commit is contained in:
Jason Biegel 2019-10-08 22:57:16 -04:00 committed by GitHub
commit f1972eb1d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -130,6 +130,9 @@ func NewFromString(value string) (Decimal, error) {
// strip the insignificant digits for more accurate comparisons.
decimalPart := strings.TrimRight(parts[1], "0")
intString = parts[0] + decimalPart
if intString == "" && parts[1] != "" {
intString = "0"
}
expInt := -len(decimalPart)
exp += int64(expInt)
} else {

View file

@ -70,6 +70,8 @@ var testTableScientificNotation = map[string]string{
"1.2345E-1": "0.12345",
"0e5": "0",
"0e-5": "0",
"0.e0": "0",
".0e0": "0",
"123.456e0": "123.456",
"123.456e2": "12345.6",
"123.456e10": "1234560000000",