Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
partially fixed, Issue # 01
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRTTV committed Jul 5, 2022
1 parent 70cef06 commit 0ec2fcb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.14.6

# Mod Properties
mod_version = 3.0.6
mod_version = 3.0.7
maven_group = ca.rttv
archives_base_name = chatcalc

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/ca/rttv/chatcalc/MathEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,13 @@ private static double eval(List<Token> tokens, boolean abs) { // recursive evalu
}
} else if (token instanceof OperatorToken operatorToken) {
Token before = i == 0 ? null : tokens.get(i - 1);
double next = tokens.get(i + 1) instanceof NumberToken numberToken ? numberToken.val() : eval(tokens.subList(i + 1, tokens.size()), abs);
if (before instanceof NumberToken) {
double prev = ((NumberToken) before).val();
double next = eval(tokens.subList(i + 1, tokens.size()), abs);
tokens.set(i - 1, new NumberToken(operatorToken.apply(prev, next)));
tokens.remove(i);
tokens.remove(i);
} else if (operatorToken.val == 45) {
double next = tokens.get(i + 1) instanceof NumberToken numberToken ? numberToken.val() : eval(tokens.subList(i + 1, tokens.size()), abs);
tokens.set(i, new NumberToken(-next));
tokens.remove(i + 1);
}
Expand Down

0 comments on commit 0ec2fcb

Please sign in to comment.