Skip to content

Commit bd4b180

Browse files
author
John J. Aylward
committed
Support for float to BigDecimal in optBigDecimal
1 parent a8d4e47 commit bd4b180

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

JSONObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,8 @@ public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) {
10201020
if (val instanceof BigInteger){
10211021
return new BigDecimal((BigInteger) val);
10221022
}
1023-
if (val instanceof Double){
1024-
return new BigDecimal(((Double) val).doubleValue());
1023+
if (val instanceof Double || val instanceof Float){
1024+
return new BigDecimal(((Number) val).doubleValue());
10251025
}
10261026
if (val instanceof Long || val instanceof Integer
10271027
|| val instanceof Short || val instanceof Byte){

0 commit comments

Comments
 (0)