ID:149940
 
I was playing a round with the -,+ and * operators, and i put this:
usr << 100 - 50 - 20 * 2
And somehow, it tells me 10. How is this possible? It should come out as 60.

Thanks

-Rcet
Rcet wrote:
DM>usr << 100 - 50 - 20 * 2</DM> And somehow, it tells me 10. How is this possible? It should come out as 60.

Nope... The correct answer to that IS indeed 10...

You're forgetting the order of operations in mathematics... Multiplication always comes before addition or subtraction...

So the 20 * 2 is evaluated first and gives the result of 40... So your problem becomes 100 - 50 - 40 = 10

In order to get the answer of 60, you need to use parentheses around the subtraction... Like so: (100 - 50 - 20) * 2

That will evaluate the expression in the parentheses and give you (30) * 2 = 60
In response to SuperSaiyanGokuX
SuperSaiyanGokuX wrote:
You're forgetting the order of operations in mathematics... Multiplication always comes before addition or subtraction...

On the first day of my 7th grade math class, our math teach promised no homework for a year if we got something like that right. We didn't.
In response to SuperSaiyanGokuX
Ohh, okay, I knew i saw that somewhere, but i forgot where to put the parens. Thanks :]

-Rcet
In response to Deadron
Deadron wrote:
On the first day of my 7th grade math class, our math teach promised no homework for a year if we got something like that right. We didn't.

On the first day of my 7th grade math class, we were promised no homework if one of us knew how/why a meter was defined as a meter.. as in, what decided how long it was. I got it right.

We still did homework. We learned a valuable lesson that day. Never trust a math teacher[1].

--Tarmas.
[1] I should already have that one down. My mother is one, and the guy she's married to is another one. The horror..
In response to Tarmas
lol just like my dad
In response to Tarmas
At least she isn't YOUR teacher! Oooo, that's really horrific! (one of my mothers was my english teacher... eek!)

~X
In response to Xooxer
I'm my girlfriend's teacher...I know that sounds really bad, but she's the one that's older than ME!
In response to Xooxer
Xooxer wrote:
At least she isn't YOUR teacher

She was. I started learning maths from her in year five. We stopped half way through eighth because she didn't want me doing calculus without telling the school.

Of course, I learned that the next summer without the school knowing, so it's not like it matters now.

--Tarmas.