Toes♀@ani.social to 196@lemmy.blahaj.zone · 1 year agoGlitch in the matrixani.socialimagemessage-square368fedilinkarrow-up1412arrow-down10
arrow-up1412arrow-down1imageGlitch in the matrixani.socialToes♀@ani.social to 196@lemmy.blahaj.zone · 1 year agomessage-square368fedilink
minus-squarecerement@slrpnk.netlinkfedilinkarrow-up52·1 year ago 16 is the right answer if you use PEMDAS only: (8 ÷ 2) × (2 + 2) 1 is the right answer if you use implicit/explicit with PEMDAS: 8 ÷ (2 × (2 + 2)) both are correct answers (as in if you don’t put in extra parentheses to reduce ambiguity, you should expect expect either answer) this is also one of the reasons why postfix and prefix notations have an advantage over infix notation postfix (HP, RPN, Forth): 2 2 + 8 2 ÷ × . prefix (Lisp): (× (÷ 8 2) (+ 2 2))
minus-squarebrian@programming.devlinkfedilinkarrow-up3·1 year agoprefix notation doesn’t need parentheses either though, at least in this case. lisp uses them for readability and to get multiple arity operators. infix doesn’t have any ambiguity either if you parenthesize all operations like that.
minus-squaresynae[he/him]@lemmy.sdf.orglinkfedilinkEnglisharrow-up2·edit-21 year agoPEMDAS is actually (PE)(MD)(AS). Those that are grouped together have equal precedence and are evaluated left to right. 8 / 2 * (2+2) 8 / 2 * 4 4 * 4 16 Edit to fix formatting, maybe?
(8 ÷ 2) × (2 + 2)
8 ÷ (2 × (2 + 2))
2 2 + 8 2 ÷ × .
(× (÷ 8 2) (+ 2 2))
prefix notation doesn’t need parentheses either though, at least in this case. lisp uses them for readability and to get multiple arity operators. infix doesn’t have any ambiguity either if you parenthesize all operations like that.
deleted by creator
PEMDAS is actually (PE)(MD)(AS). Those that are grouped together have equal precedence and are evaluated left to right.
8 / 2 * (2+2)
8 / 2 * 4
4 * 4
16
Edit to fix formatting, maybe?