Skip to content

Commit

Permalink
Merge pull request #137 from lantw44/master
Browse files Browse the repository at this point in the history
Fix decoding of .0
  • Loading branch information
njason authored Oct 9, 2019
2 parents 2677b5d + f39378d commit f1972eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f1972eb

Please sign in to comment.