This should be easy...

Order of operations :)

Perenthesis, Exponent, Multiply/Divide, Add/Subtract

so-

8 + 8 - 2 * (4 + 2 * 3)
16 - 2 * (4 + 2 * 3)
14 * (4 + 2 * 3)
14 * (4 + 6)
14 * 10
140


using the * notation is usually what will mess me up, so I always write things out using parenthesis instead of multiplication-

(8 + 8 - 2)(4 + (2)(3))

which should be a bit easier to understand... (in my mind anyways)
 
Yeah, exactly, that's my opinion, too.

So (8 + 8 - 2)(4 + [2] [3] ) would be

(16 - 2)(4 + [2] [3] )
(14) (4 + [2] [3] )
(14) (4 + [2] [3] )
(14) (4 + 6)
(14) (10)
140

but, logically, 8 + 8 - 2 * (4 + 2 * 3) would be

16 - 2 * (4 + 2 * 3)
14 * (4 + 2 * 3)
14 * (18)
252

because 4 + 2 = 6, and 6 * 3 = 18.

Any thoughts?
 
Code:
$ bc
bc 1.05
Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
8 + 8 - 2 * (4 + 2 * 3)
-4

Gotta love those precedences...
8 + 8 - 2 * ( 4 + 6 )
8 + 8 - 2 * 10
8 + 8 - 20
-4
 
Ish- I fudged.

Bad math man... bad.

Thank god I don't need to pay attention to order of operations while I'm coding... I just need to keep my numbers straight.

Ugh...

I M WEE TODD DID
 
Originally posted by blb
Code:
$ bc
bc 1.05
Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
8 + 8 - 2 * (4 + 2 * 3)
-4

Gotta love those precedences...
8 + 8 - 2 * ( 4 + 6 )
8 + 8 - 2 * 10
8 + 8 - 20
-4

What? :p
 
He's right... for some reason we assume that we're dealing with two pieces of an equation, and treat both as if they're in parenthesis.


(8 + 8 - 2) * (4 + 2 * 3)

I solved this.


8 + 8 - (2 * (4 + (2 * 3)))

That's what I should have solved.

the 2 * blah blah should be taken care of BEFORE we subtract from (8 + 8).
 
Back
Top