Order of Operations
12Me21Created:
wrong
In section 32 of the manual (Standard BASIC Spec.) it has a table showing the order of operations in SB.This is incorrect
- Contents enclosed in ()
- - (Unary), NOT (One's complement), ! (Logical inversion)
- *, /, DIV (Integer division), MOD
- +, - (Binomial)
- <<, >> (Shift)
- ==, !=, <, <=, >, >=
- AND, OR, XOR (Bitwise operations)
- &&, || (Logical operators. With shortcuts)
- -(Unary), !(logical), NOT(bitwise)
- *, /, DIV, MOD(Integer)
- +, -
- <<, >>(arithmetic)
- <, <=, >, >=, ==, != *
- AND(bitwise)
- XOR(bitwise), OR(bitwise) *
- &&(logical)
- ||(logical)
W-...wait, I've been using AND this whole time when I should've been using the logical version &&? Does SB support the caret power notation (^)?Don't most programming languages use the caret for XOR anyways?
yes, but many BASIC dialects use ^ for exponents, and xor is already XOR in SB, so they *could* (should) have done it.W-...wait, I've been using AND this whole time when I should've been using the logical version &&? Does SB support the caret power notation (^)?Don't most programming languages use the caret for XOR anyways?
with something like A()*B()*C(), it seems to evaluate: C, B, A, A*B, AB*C. functions are normally done right to left, but operators with the same precidence are usually left to right like in normal math. An exception is A()&&B() where A is evaluated first, and B only checked if A is not 0. I think some operations (== maybe?) are done right to left, like A==B==C might check B==C first (but I'm not sure)
Are contents enclosed in parentheses not calculated?
Okie dokie