Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is BIMDAS busted?
#1
The BIMDAS rules (universal priority rules for math) sets priority for math operations as
Brackets, Indices, Multiplication, Division, Addition, Subtraction.
Within the BIMDAS rules, the expression 5+4*3^2-1/2 becomes (3^2)*4/2+5-1
                                                                                               B   I   M  D   A  S
and the result is 22.

With the re-arrangement, Phoenix returns 22, as expected.
but when entered as 5 + 4 * 3 ^ 2 - 1 / 2, it returns 40.5

Does this mean we must apply the BIMDAS rules manually, or am I missing something?  Huh
Print "Am I missing something here?"
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#2
You're doing it all wrong, even by BIMDAS standards:
5+4*3^2-1/2 --- original
5 + 4 * (3^2) -1/2 --- first step with Indices (the parenthesis was just my way to highlight this step.)
5 + 4 * 9 - 1/2 -- what we get after we solve that step.
5 + (4 * 9) - 1/2 -- the next step, where we do multiplication.
5 + 36 - 1/2 --- the result from that step
5 + 36 - (1/2) -- the next step, where we do Division
5 + 36 - 0.5 --- the result from that step
(5 + 36) - 0.5 --- Now we do the addition.
41 - 0.5 ---- which gives us this result
(41 - 0.5) --- Finally do your subtraction
40.5

Looks like the answer is correct!!



And, if you want to know the extended ruleset that we use for order of operations, then look below.




QB64's order of operations (as ripped from my math evaluator): 
'Exponents with PL 20
i = i + 1: OName(i) = "^": PL(i) = 20
i = i + 1: OName(i) = "SQR": PL(i) = 20
i = i + 1: OName(i) = "ROOT": PL(i) = 20
'Multiplication and Division PL 30
i = i + 1: OName(i) = "*": PL(i) = 30
i = i + 1: OName(i) = "/": PL(i) = 30
'Integer Division PL 40
i = i + 1: OName(i) = "\": PL(i) = 40
'MOD PL 50
i = i + 1: OName(i) = "MOD": PL(i) = 50
'Addition and Subtraction PL 60
i = i + 1: OName(i) = "+": PL(i) = 60
i = i + 1: OName(i) = "-": PL(i) = 60

'Relational Operators =, >, <, <>, <=, >= PL 70
i = i + 1: OName(i) = "<>": PL(i) = 70 'These next three are just reversed symbols as an attempt to help process a common typo
i = i + 1: OName(i) = "><": PL(i) = 70
i = i + 1: OName(i) = "<=": PL(i) = 70
i = i + 1: OName(i) = ">=": PL(i) = 70
i = i + 1: OName(i) = "=<": PL(i) = 70 'I personally can never keep these things straight. Is it < = or = <...
i = i + 1: OName(i) = "=>": PL(i) = 70 'Who knows, check both!
i = i + 1: OName(i) = ">": PL(i) = 70
i = i + 1: OName(i) = "<": PL(i) = 70
i = i + 1: OName(i) = "=": PL(i) = 70
'Logical Operations PL 80+
i = i + 1: OName(i) = "NOT": PL(i) = 80
i = i + 1: OName(i) = "AND": PL(i) = 90
i = i + 1: OName(i) = "OR": PL(i) = 100
i = i + 1: OName(i) = "XOR": PL(i) = 110
i = i + 1: OName(i) = "EQV": PL(i) = 120
i = i + 1: OName(i) = "IMP": PL(i) = 130
i = i + 1: OName(i) = ",": PL(i) = 1000
Reply
#3
Thanks Steve.
You're right, I had it all wrong!
Not sure why, but it seems we can't just re-phrase the whole expression, but just complete each operation step-by-step.
Sorry for the trivia, it just didn't "add up" for me!
I'll go away and play some more.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply




Users browsing this thread: 1 Guest(s)