Skip to content

Commit

Permalink
Parse BigInteger directly in DecimalType
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Grześlowski <[email protected]>
  • Loading branch information
magx2 committed Oct 20, 2024
1 parent e027bb5 commit 44b0f0a
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.openhab.core.library.types;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
Expand Down Expand Up @@ -57,6 +58,8 @@ public DecimalType(Number value) {
this.value = type.toBigDecimal();
} else if (value instanceof BigDecimal decimal) {
this.value = decimal;
}else if (value instanceof BigInteger integer) {
this.value = new BigDecimal(integer);
} else {
this.value = new BigDecimal(value.toString());
}
Expand Down

0 comments on commit 44b0f0a

Please sign in to comment.