FIX: Autoscale scaled wrong for negative exponents
This commit is contained in:
parent
27155cdf19
commit
0b99043d5a
@ -18,7 +18,7 @@ public class Autoscale {
|
|||||||
final double abs = sourceUnit.factor * Arrays.stream(values).map(Math::abs).max().orElse(0);
|
final double abs = sourceUnit.factor * Arrays.stream(values).map(Math::abs).max().orElse(0);
|
||||||
final double exp = Math.max(0, Math.log10(abs));
|
final double exp = Math.max(0, Math.log10(abs));
|
||||||
final int group = (int) Math.floor(exp / 3);
|
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;
|
final int index = (SI_PREFIX.length - 1) / 2 + group;
|
||||||
this.unit = SI_PREFIX[index] + sourceUnit.base.unit;
|
this.unit = SI_PREFIX[index] + sourceUnit.base.unit;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user