Browse Source

Fix order of operations on arithmetic

I did not read the docs close enough. Arithmetic is done
`Y operand X`, not the other way around.
ApisNecros 1 year ago
parent
commit
386a554ac2
1 changed files with 5 additions and 5 deletions
  1. 5 5
      starfish.js

+ 5 - 5
starfish.js

@@ -175,31 +175,31 @@ class CodeBox {
             case "+": {
                 const x = this.stack.Pop();
                 const y = this.stack.Pop();
-                this.stack.Push(x + y);
+                this.stack.Push(y + x);
                 break;
             }
             case "-": {
                 const x = this.stack.Pop();
                 const y = this.stack.Pop();
-                this.stack.Push(x - y);
+                this.stack.Push(y - x);
                 break;
             }
             case "*": {
                 const x = this.stack.Pop();
                 const y = this.stack.Pop();
-                this.stack.Push(x * y);
+                this.stack.Push(y * x);
                 break;
             }
             case ",": {
                 const x = this.stack.Pop();
                 const y = this.stack.Pop();
-                this.stack.Push(x / y);
+                this.stack.Push(y / x);
                 break;
             }
             case "%": {
                 const x = this.stack.Pop();
                 const y = this.stack.Pop();
-                this.stack.Push(x % y);
+                this.stack.Push(y % x);
                 break;
             }
             case "n":