aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-06-28 06:26:01 +1000
committerGitHub <noreply@github.com>2023-06-27 22:26:01 +0200
commite68e5847b798d17a4d651818a6e55fba45da8a4e (patch)
tree632da292233e0ee060285ede9e197acb7036e018
parent5862bb5cbf4712a0a6dca9b4ecbd7715f90c6b14 (diff)
downloadNotEnoughUpdates-e68e5847b798d17a4d651818a6e55fba45da8a4e.tar.gz
NotEnoughUpdates-e68e5847b798d17a4d651818a6e55fba45da8a4e.tar.bz2
NotEnoughUpdates-e68e5847b798d17a4d651818a6e55fba45da8a4e.zip
fixing crash in neu calculator (#746)
fixing crash in calculator
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java
index a58fc8a6..0762d107 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java
@@ -299,6 +299,11 @@ public class Calculator {
Token rightToken = rpnTokens.get(rpnTokens.indexOf(command) - 1);
throw new CalculatorException(right + " has a decimal, pick a power that is non-decimal", rightToken.tokenStart, rightToken.tokenLength);
}
+
+ if (right.doubleValue() < 0) {
+ Token rightToken = rpnTokens.get(rpnTokens.indexOf(command) - 1);
+ throw new CalculatorException(right + " is a negative number, pick a power that is positive", rightToken.tokenStart, rightToken.tokenLength);
+ }
values.push(left.pow(right.intValue()).setScale(2, RoundingMode.HALF_UP));
break;
case "x":