summaryrefslogtreecommitdiff
path: root/src/org/unitConverter/unit/UnitDatabase.java
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2020-09-07 15:15:20 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2020-09-07 15:15:20 -0500
commit5a7e8f6fcb175b238eb1d5481513b35039107a3e (patch)
tree3078cd98b290fbab46ea9a6cc181e3e18e3f62e7 /src/org/unitConverter/unit/UnitDatabase.java
parent21dc2db1cccfd9781bbdbbbafdacf88630cab5c0 (diff)
Created an UncertainDouble class for uncertainty operations.
Diffstat (limited to 'src/org/unitConverter/unit/UnitDatabase.java')
-rw-r--r--src/org/unitConverter/unit/UnitDatabase.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/org/unitConverter/unit/UnitDatabase.java b/src/org/unitConverter/unit/UnitDatabase.java
index 9812bd0..9ca9617 100644
--- a/src/org/unitConverter/unit/UnitDatabase.java
+++ b/src/org/unitConverter/unit/UnitDatabase.java
@@ -46,6 +46,7 @@ import org.unitConverter.math.ConditionalExistenceCollections;
import org.unitConverter.math.DecimalComparison;
import org.unitConverter.math.ExpressionParser;
import org.unitConverter.math.ObjectProduct;
+import org.unitConverter.math.UncertainDouble;
/**
* A database of units, prefixes and dimensions, and their names.
@@ -1134,7 +1135,7 @@ public final class UnitDatabase {
// exponent function - first check if o2 is a number,
if (exponentValue.canConvertTo(SI.ONE)) {
// then check if it is an integer,
- final double exponent = exponentValue.getValue();
+ final double exponent = exponentValue.getValueExact();
if (DecimalComparison.equals(exponent % 1, 0))
// then exponentiate
return base.toExponent((int) (exponent + 0.5));
@@ -1650,7 +1651,8 @@ public final class UnitDatabase {
final BigDecimal number = new BigDecimal(name);
final double uncertainty = Math.pow(10, -number.scale());
- return LinearUnitValue.of(SI.ONE, number.doubleValue(), uncertainty);
+ return LinearUnitValue.of(SI.ONE,
+ UncertainDouble.of(number.doubleValue(), uncertainty));
} catch (final NumberFormatException e) {
return LinearUnitValue.getExact(this.getLinearUnit(name), 1);
}