From 0b99043d5a7dbda144d7fcd603b24bd3c739e750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Tue, 25 Feb 2025 11:57:40 +0100 Subject: [PATCH] FIX: Autoscale scaled wrong for negative exponents --- src/main/java/de/ph87/data/value/Autoscale.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/ph87/data/value/Autoscale.java b/src/main/java/de/ph87/data/value/Autoscale.java index 5f14b4d..c235966 100644 --- a/src/main/java/de/ph87/data/value/Autoscale.java +++ b/src/main/java/de/ph87/data/value/Autoscale.java @@ -18,7 +18,7 @@ public class Autoscale { final double abs = sourceUnit.factor * Arrays.stream(values).map(Math::abs).max().orElse(0); final double exp = Math.max(0, Math.log10(abs)); final int group = (int) Math.floor(exp / 3); - this.factor = sourceUnit.factor * Math.pow(10, group * 3); + this.factor = sourceUnit.factor * Math.pow(10, -group * 3); final int index = (SI_PREFIX.length - 1) / 2 + group; this.unit = SI_PREFIX[index] + sourceUnit.base.unit;