File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
src/main/java/com/jsoniter Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 11package com .jsoniter ;
22
3+ import java .io .IOException ;
4+ import java .math .BigDecimal ;
5+ import java .math .BigInteger ;
6+
37import com .jsoniter .any .Any ;
48import com .jsoniter .spi .JsonException ;
59import com .jsoniter .spi .Slice ;
610
7- import java .io .IOException ;
8- import java .math .BigInteger ;
9-
1011class IterImpl {
1112
1213 private static BigInteger maxLong = BigInteger .valueOf (Long .MAX_VALUE );
@@ -469,7 +470,10 @@ static final double readDouble(final JsonIterator iter) throws IOException {
469470 decimalPart = -decimalPart ;
470471 int decimalPlaces = iter .head - start ;
471472 if (decimalPlaces > 0 && decimalPlaces < IterImplNumber .POW10 .length && (iter .head - oldHead ) < 10 ) {
472- return value + (decimalPart / (double ) IterImplNumber .POW10 [decimalPlaces ]);
473+ BigDecimal integerPart = new BigDecimal (value );
474+ BigDecimal fractionalPart = new BigDecimal ((decimalPart / (double ) IterImplNumber .POW10 [decimalPlaces ]));
475+ BigDecimal result = integerPart .add (fractionalPart ).setScale (decimalPlaces ,BigDecimal .ROUND_HALF_UP );
476+ return result .doubleValue ();
473477 } else {
474478 iter .head = oldHead ;
475479 return IterImplForStreaming .readDoubleSlowPath (iter );
You can’t perform that action at this time.
0 commit comments