Skip to content

Commit 1d9d0b3

Browse files
committed
simplify
1 parent ba7fdc4 commit 1d9d0b3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

client/v2/autocli/query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ func encoder(encoder aminojson.Encoder) aminojson.Encoder {
206206
}
207207

208208
amount := msg.Get(amountField).String()
209-
if len(amount) > math.LegacyPrecision {
210-
amount = amount[:len(amount)-math.LegacyPrecision] + "." + amount[len(amount)-math.LegacyPrecision:]
211-
} else if len(amount) == math.LegacyPrecision {
209+
decimalPlace := len(amount) - math.LegacyPrecision
210+
if decimalPlace > 0 {
211+
amount = amount[:decimalPlace] + "." + amount[decimalPlace:]
212+
} else if decimalPlace == 0 {
212213
amount = "0." + amount
213214
} else {
214-
decimalPlace := len(amount) - math.LegacyPrecision
215215
amount = "0." + strings.Repeat("0", -decimalPlace) + amount
216216
}
217217

0 commit comments

Comments
 (0)