From 44b0f0a6a8d84d971ba9646a8bc2210480e6a751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grze=C5=9Blowski?= Date: Sun, 20 Oct 2024 13:25:32 +0200 Subject: [PATCH 1/2] Parse BigInteger directly in DecimalType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 41ce58fffcd..fb9c0e76ea9 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 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()); } From 1b5932ad0c5fd1ebf3f48a42ac0ed75f6d5aabdd Mon Sep 17 00:00:00 2001 From: J-N-K Date: Sun, 20 Oct 2024 14:25:27 +0200 Subject: [PATCH 2/2] Update bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java Signed-off-by: J-N-K --- .../main/java/org/openhab/core/library/types/DecimalType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fb9c0e76ea9..594c03d3928 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 @@ -58,7 +58,7 @@ public DecimalType(Number value) { this.value = type.toBigDecimal(); } else if (value instanceof BigDecimal decimal) { this.value = decimal; - }else if (value instanceof BigInteger integer) { + } else if (value instanceof BigInteger integer) { this.value = new BigDecimal(integer); } else { this.value = new BigDecimal(value.toString());