Skip to content

Commit 9c1cd83

Browse files
committed
fix JSONReader.Feature.UseBigDecimalForDoubles when exponent != 0 (#3382)
1 parent d44e4a4 commit 9c1cd83

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

core/src/main/java/com/alibaba/fastjson2/JSONReader.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -3093,10 +3093,14 @@ public final Number getNumber() {
30933093
}
30943094
}
30953095

3096-
if (exponent != 0 && (context.features & (Feature.UseBigDecimalForDoubles.mask | Feature.UseBigDecimalForFloats.mask)) == 0) {
3096+
if (exponent != 0) {
30973097
String decimalStr = decimal.toPlainString();
3098-
return Double.parseDouble(
3099-
decimalStr + "E" + exponent);
3098+
if ((context.features & (Feature.UseBigDecimalForDoubles.mask | Feature.UseBigDecimalForFloats.mask)) == 0) {
3099+
return Double.parseDouble(
3100+
decimalStr + "E" + exponent);
3101+
} else {
3102+
return new BigDecimal(decimalStr + "E" + exponent);
3103+
}
31003104
}
31013105

31023106
if ((context.features & Feature.UseDoubleForDecimals.mask) != 0) {

0 commit comments

Comments
 (0)