summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnits/unit/UnitPrefix.java
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2024-03-03 11:23:03 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2024-03-03 11:23:03 -0500
commit4a17e32274f991014edcfa22402d7207361f69f1 (patch)
treeb3bda9bc045882bcef140503b665f82898ba8d12 /src/main/java/sevenUnits/unit/UnitPrefix.java
parent0b296213ce91c2aa0e596419addd42fc4b4f5e1a (diff)
Add + and - to prefixes
This was added to be consistent with the data file spec, which was changed for consistency with unit expressions. It may not be a common expression, but it's a bit weird that you can use +/- in units but not prefixes, even though they're in the same file!
Diffstat (limited to 'src/main/java/sevenUnits/unit/UnitPrefix.java')
-rw-r--r--src/main/java/sevenUnits/unit/UnitPrefix.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/sevenUnits/unit/UnitPrefix.java b/src/main/java/sevenUnits/unit/UnitPrefix.java
index e1f7788..824f60b 100644
--- a/src/main/java/sevenUnits/unit/UnitPrefix.java
+++ b/src/main/java/sevenUnits/unit/UnitPrefix.java
@@ -158,6 +158,22 @@ public final class UnitPrefix implements Nameable {
}
/**
+ * Adds {@code other} to this prefix and returns the result.
+ * @since 2024-03-03
+ */
+ public UnitPrefix plus(final UnitPrefix other) {
+ return valueOf(this.getMultiplier() + other.getMultiplier());
+ }
+
+ /**
+ * Subtracts {@code other} from this prefix and returns the result.
+ * @since 2024-03-03
+ */
+ public UnitPrefix minus(final UnitPrefix other) {
+ return valueOf(this.getMultiplier() - other.getMultiplier());
+ }
+
+ /**
* Multiplies this prefix by {@code other}.
*
* @param other prefix to multiply by