From 1325d803437193cbe2c2535628630e65f2a7c3aa Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 20 Oct 2024 16:01:59 +0200 Subject: [PATCH] Parse BigInteger directly in DecimalType (#4417) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Parse BigInteger directly in DecimalType Signed-off-by: Martin GrzeĊ›lowski --- .../main/java/org/openhab/core/library/types/DecimalType.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java index 41ce58fff..594c03d39 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java @@ -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; @@ -57,6 +58,8 @@ public class DecimalType extends Number implements PrimitiveType, State, Command 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()); }