File tree 1 file changed +8
-4
lines changed
src/main/java/com/jsoniter
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
package com .jsoniter ;
2
2
3
+ import java .io .IOException ;
4
+ import java .math .BigDecimal ;
5
+ import java .math .BigInteger ;
6
+
3
7
import com .jsoniter .any .Any ;
4
8
import com .jsoniter .spi .JsonException ;
5
9
import com .jsoniter .spi .Slice ;
6
10
7
- import java .io .IOException ;
8
- import java .math .BigInteger ;
9
-
10
11
class IterImpl {
11
12
12
13
private static BigInteger maxLong = BigInteger .valueOf (Long .MAX_VALUE );
@@ -469,7 +470,10 @@ static final double readDouble(final JsonIterator iter) throws IOException {
469
470
decimalPart = -decimalPart ;
470
471
int decimalPlaces = iter .head - start ;
471
472
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 ();
473
477
} else {
474
478
iter .head = oldHead ;
475
479
return IterImplForStreaming .readDoubleSlowPath (iter );
You can’t perform that action at this time.
0 commit comments