mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-25 22:00:49 +01:00
commit
f1972eb1d1
2 changed files with 5 additions and 0 deletions
|
@ -130,6 +130,9 @@ func NewFromString(value string) (Decimal, error) {
|
||||||
// strip the insignificant digits for more accurate comparisons.
|
// strip the insignificant digits for more accurate comparisons.
|
||||||
decimalPart := strings.TrimRight(parts[1], "0")
|
decimalPart := strings.TrimRight(parts[1], "0")
|
||||||
intString = parts[0] + decimalPart
|
intString = parts[0] + decimalPart
|
||||||
|
if intString == "" && parts[1] != "" {
|
||||||
|
intString = "0"
|
||||||
|
}
|
||||||
expInt := -len(decimalPart)
|
expInt := -len(decimalPart)
|
||||||
exp += int64(expInt)
|
exp += int64(expInt)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -70,6 +70,8 @@ var testTableScientificNotation = map[string]string{
|
||||||
"1.2345E-1": "0.12345",
|
"1.2345E-1": "0.12345",
|
||||||
"0e5": "0",
|
"0e5": "0",
|
||||||
"0e-5": "0",
|
"0e-5": "0",
|
||||||
|
"0.e0": "0",
|
||||||
|
".0e0": "0",
|
||||||
"123.456e0": "123.456",
|
"123.456e0": "123.456",
|
||||||
"123.456e2": "12345.6",
|
"123.456e2": "12345.6",
|
||||||
"123.456e10": "1234560000000",
|
"123.456e10": "1234560000000",
|
||||||
|
|
Loading…
Reference in a new issue