Workshop

The BODMAS Rule

We all know it, right? right??

Sushant Ray8/30/20261 min read
part of PARSE IT!string searchloops
The BODMAS Rule

…Do I even need to yap about it? Anybody who has passed middle-school knows about the BODMAS (sometimes called PEMDAS) rule. But since we are doing this, lemme just revise it to you real quick:

BODMAS

BODMAS stands for:

Brackets —> Orders —> Division —> Multiplication —> Addition —> Subtraction

But that’s not entirely true. Division and multiplication have the same precedence, as well as addition and subtraction. The only catch is that everything is evaluated from left to right. So if subtraction comes before addition, we’ll subtract first. Same for multiplication vs. divison.

  • Orders are exponents (and roots), which we won’t get into for now :)

So BODMAS—summarized is basically: Multiplication and division happen before addition and subtraction. That is all we need for our parser!

Drillsssssssss

Let’s get the brain running with some quick drills. How quickly can you evaluate these in your mind?

  • 3 + 5 * 2

    18 ÷ 3 - 2

    5 × (4 + 3)

    20 - 3 × (4 + 2)

I hope you got every one of it right (it’ll be pretty embarrassing if you didn’t…)

And that’s kind of it… lol. See you in the next article :)

View all Articles