Skip to content

Commit

Permalink
Fix array subtraction
Browse files Browse the repository at this point in the history
  • Loading branch information
phase committed Jul 26, 2015
1 parent 6970231 commit 11e3afe
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/xyz/jadonfowler/o/O.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,21 @@ else if (a instanceof String || b instanceof String) {
else if (c == '-') {
if (stacks[sid].peek() instanceof ArrayList<?>) {
double ans = 0;
boolean set = false;
for (Object o : (ArrayList<Object>) stacks[sid].pop()) {
if (o instanceof Integer) {
ans -= (int) o;
if (!set) {
ans = (int) o;
set = true;
}
else ans -= (int) o;
}
else if (o instanceof Double) {
ans -= (double) o;
if (!set) {
ans = (double) o;
set = true;
}
else ans -= (double) o;
}
}
stacks[sid].push(ans);
Expand Down

0 comments on commit 11e3afe

Please sign in to comment.