ID:273006
 
A simple mathematic equation used to figure out what x equals. What I am curious as to: does DM use BODMAS? It seems quite obvious, but I want to check and be sure. Example,

if I input:

1+1*8==16


Will it return true? And if I input:

1+1*8==15


Will it return false?
From the DM reference:

Operators are used extensively in DM to compute numerical values.

The DM operators are:

[] () . / :
~ ! - ++ --
**
* / %
+ -
< <= > >=
<< >>
== != <>
& ^ |
&&
||
?
= += -= *= /= &= |= ^= <<= >>=

Each line has higher order of operations than the next. Operators within a line have equal precedence and therefore are processed from left to right as they occur in an expression.


So yes, multiplication is a higher precedence then addition.
In response to Jp
You must not understand what I'm asking here.

As taught to me in year 6, BODMAS stands for:

Brackets
Of
Division
Multiplication
Addition
Subtraction

And according to BODMAS, all things in an equation must follow this formula to calculate said equation properly:

Anything inside the brackets.
From left to right, Division and Multiplication (whichever comes first).
From left to right, Addition and Subtraction (whichever comes first).

What I want to know is whether BODMAS is used in DM.
In response to Demon_F0rce
I understand what you're asking plenty fine, and I gave you all the info you need.

In programming languages, you generally don't use an acronym like BEDMAS (You missed exponentiation) because there are rather a lot of operators. Rather, you talk about operator precedence - the higher an operator is in the list, the earlier it gets done. So you now know that the bitshift operator happens after addition, for example, so 1 + 2 << 1 is 3 << 1 is 9.

If you look at the list, parentheses come before exponentiation come before multiplication/division come before addition/subtraction
In response to Jp
I see. It was just me not understanding your answer then XD. Thanks for that.
In response to Jp
What about 2*2/2 ? Result will be different depending how it will do it (2*2)/2 or 2*(2/2)? In that list * is before / so I guess multiply will be first. What about 2/2*2 ? :) Will it return 2 or 0.5 ?
In response to Ripiz
(2*2)/2 = 4/2 = 2
2*(2/2) = 2*1 = 2

;)

But there are situations where it could be different (1 + 2 - 3 - (1+2)-3 or 1+(2-3)?). In those cases:

Operators within a line have equal precedence and therefore are processed from left to right as they occur in an expression.


That is, 1 + 2 - 3 is (1 + 2) - 3, 2*2/2 is (2*2)/2, and 2/2*2 is (2/2)*2
In response to Jp
With same numbers it wasn't best example. What about 2/2*2 ? Which order it will go? It can result 2 either 0.5
In response to Ripiz
Jp wrote:
Operators within a line have equal precedence and therefore are processed from left to right as they occur in an expression.

That is, 1 + 2 - 3 is (1 + 2) - 3, 2*2/2 is (2*2)/2, and 2/2*2 is (2/2)*2
I don't know what country you're in (probably somewhere in Europe judging by how you said "year 6" and not something like "6th grade"), but here in the United States (as far as I know), we're taught about "Mrs. Pemdas". The "Mrs." holds no value but the "Pemdas" does.

P - parentheses
E - exponents
M - multiplication
D - division
A - addition
S - subtraction

That's the order of operations I was taught, and I'm sure many many others. Your method doesn't even speak of exponents, but brackets can be interchanged with parentheses.

(1 + 1 * 8) will return 9, not 16 (to answer your question). You can, however, manipulate that expression by switching around the positions of the parentheses (or brackets if you use those), to get the 16 answer you might be looking for. (1 + 1) * 8

Note: in DM, you must use parentheses, not brackets in these numerical cases.

Note2a: multiplication & division are read as a single order of operation, and neither takes precedence over the other.

Note2b: addition & subtraction are read as a single order of operation, and neither takes precedence over the other.
In response to Spunky_Girl
Australia
In response to Spunky_Girl
Spunky_Girl wrote:
I don't know what country you're in (probably somewhere in Europe judging by how you said "year 6" and not something like "6th grade"), but here in the United States (as far as I know), we're taught about "Mrs. Pemdas".

http://en.wikipedia.org/wiki/Order_of_operations#Mnemonics

You folks down there in the states are the only ones who use the PEMDAS mnemonic, so there was no real need for the extra clarification and lesson, considering the poster has a clear understanding of the order of operations and was just curious as to whether BYOND follows them or not.

brackets can be interchanged with parentheses.
(1 + 1) * 8
Note: in DM, you must use parentheses, not brackets in these numerical cases.

Again, you Statesy-folk disagree with the rest of the world...parentheses are the same thing as brackets.
In response to Ephemerality
Ephemerality wrote:
You folks down there in the states are the only ones who use the PEMDAS mnemonic, so there was no real need for the extra clarification and lesson, considering the poster has a clear understanding of the order of operations and was just curious as to whether BYOND follows them or not.

Clarification? I was simply telling him what I was taught and pointing out how the method he was taught didn't mention anything about exponents. Then, if I just said "pemdas" without explaining it, he might've been totally lost as to what I was talking about.

Again, you Statesy-folk disagree with the rest of the world...parentheses are the same thing as brackets.

Not in DM they're not. Next time read my post, please. And also, don't generalize us "statesy-folk" seeing as how we are not all the same. I never said his method was wrong, or it was bad. I said that in Dream Maker, brackets do not mean the same thing as parentheses. As far as I know, only in math do brackets and parentheses hold the same meaning (again, as far as I know. correct me if I'm wrong, but know that I do not know any other programming language than DM right now).
In response to Ephemerality
To be fair, I believe one reason why the her explanation was phrased as if the poster didn't understand order of operations was because their example made it look like they didn't. If they were expecting 1+1*8 to equal 16, then they really didn't understand the correct order. I think it was just a typo, or a simple mistake, but you can't really blame Spunky_Girl for being a little "patronizing".
In response to Ephemerality
Ephemerality wrote:
http://en.wikipedia.org/wiki/Order_of_operations#Mnemonics

You folks down there in the states are the only ones who use the PEMDAS mnemonic, so there was no real need for the extra clarification and lesson, considering the poster has a clear understanding of the order of operations and was just curious as to whether BYOND follows them or not.

Demon_F0rce said "Brackets Of Division Multiplication Addition Subtraction", which was not correct, as "Of" does not mean exponentiation, it means multiplication (as the wikipedia article said). He may have meant "Brackets Order Division etc.", again as the article said.

Again, you Statesy-folk disagree with the rest of the world...parentheses are the same thing as brackets.

Parentheses are specifically (). Brackets are <> {} [] (). Technically, you could argue that saying "brackets" is therefore more correct as [] and {} are used as grouping symbols as well, but then I'd point out that <> are used for another operator (inner product), as well as {} being used to denote sets, so both "brackets" and "parentheses" are wrong and the whole thing is simplified to help people learn a simple concept without having to deal with the technicalities.

Though I will concede that "bracket" is easier to spell than "parenthesis". And MUCH easier to pluralize.
In response to Chessmaster_19
I apologize if it sounded like I was patronizing him. I did not mean to. I was teaching him about the concept I learned in school. Not to single out that wherever he goes is a bad school. The main reason I told him about Pemdas was because BODMAS didn't mention anything about exponents (from the way he explained it anyways). I'm sorry if I patronized you Demon :(