Does Unity use PEMDAS or BODMAS? Also BOMDAS Qs

Is BODMAS for coding programs? Lastly does it divide/multiply whatever is left to right and same as +/- ? I’m a little confused. I’ve always used PEMDAS so I am a little confused as I thought the BODMAS video was telling me division is before multiplication and not executed whatever is left to right though depends on the program, the start of this video makes me a little confused. Is it just PEMDAS essentially where division/multiplication and subtraction/addition is calculated based on whatever comes first or only division first then multiplication etc…

Hi @Kaiya,
When you’re doing calculations by hand, we solve multiplication/division from left to right.
This is also how the vast majority of programming languages handle things as well, so you shouldn’t have to worry about it too much.
(I’m not aware of any that don’t but Ben has probably encountered some arcane language in the past where it did, which is why he mentioned it).

If we look at a straight forward example: 3 * 4 ÷ 2 = (3 * 4) ÷ 2 = 3 * (4 ÷ 2) = 6

The main thing is that multiplication/division always has a higher precedence than addition/subtraction.

I hope that helps answer your question and clears up any confusion.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms