Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Order of Operations | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7553/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-09-05 07:27 AM Link | Quote
I know the basic order of operations when doing math, but that only covers the basic stuff (brackets, exponents, division, multiplication, addition and subtraction). Where do other operations like XOR and AND fit into this?
knuck

Hinox
Banned until 19-58-5815: trolling, flaming, spamming, being a general fucktard...
Level: 62

Posts: 1683/1818
EXP: 1894574
For next: 90112

Since: 03-15-04

Since last post: 14 hours
Last activity: 9 hours
Posted on 10-09-05 08:19 AM Link | Quote
I think those operators are the last thing to be calculated. Like, if the equation is X²-2/3 AND Y, it'd go
(X²-2/3) AND Y

I can be wrong though.
mcw

Red Paratroopa
Level: 17

Posts: 136/164
EXP: 22756
For next: 1987

Since: 07-08-05
From: don't you want my a/s too?

Since last post: 8 hours
Last activity: 5 hours
Posted on 10-09-05 08:23 AM Link | Quote
i remember seeing a chart showing the exact order of.. everything. it was nice, i wish i remembered the url.
but to be safe, just use parenthesis.
but knuck is right, it's after all the math operations get figured out.


(edited by mcw on 10-08-05 11:24 PM)
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7556/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-09-05 09:27 AM Link | Quote
Makes sense, but what about when there are multiple expressions, like 2 + 2 XOR 7 AND 3?
neotransotaku

Baby Mario
戻れたら、
誰も気が付く
Level: 87

Posts: 3951/4016
EXP: 6220548
For next: 172226

Since: 03-15-04
From: Outside of Time/Space

Since last post: 11 hours
Last activity: 1 hour
Posted on 10-09-05 10:57 AM Link | Quote
logical comes after arithmetic, and logical is evaluated left to right--this is how lazy evaluation works...

so, for your statement the order is

((2 + 2) XOR 7) AND 3
rg_

Goomba
Level: 8

Posts: 22/26
EXP: 1964
For next: 223

Since: 03-27-05

Since last post: 21 hours
Last activity: 12 hours
Posted on 10-09-05 02:03 PM Link | Quote
It's called operator precedence and it's language-dependent. Google it for your favourite languages.
beneficii

Lakitu
Level: 36

Posts: 546/567
EXP: 299656
For next: 8454

Since: 06-27-04
From: Cordova, TN, USA

Since last post: 14 hours
Last activity: 6 hours
Posted on 10-10-05 07:56 PM Link | Quote
HH,

Just do it like I do: use parantheses.

Ha ha!
aioria1981

Ninji
Level: 20

Posts: 163/234
EXP: 36701
For next: 5738

Since: 07-20-05
From: Viña del Mar, Chile

Since last post: 5 days
Last activity: 5 days
Posted on 10-10-05 09:06 PM Link | Quote
In which language are you working?
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7594/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-11-05 12:27 AM Link | Quote
Well, C technically, but I'm writing code to parse equations so it really doesn't make much difference. And I can't be sure people will use brackets.
Squash Monster

New Age Retro Hippie
Togateiru Fohku Kohgeki!!
GRUNGE no HAMSTER otona bite
Peace love and turnpike!

Level: 40

Posts: 665/677
EXP: 430507
For next: 10802

Since: 03-15-04
From: Maryland (of the Country Between Canada and Mexico)

Since last post: 5 hours
Last activity: 5 hours
Posted on 10-12-05 05:01 AM Link | Quote
The cplusplus.com tutorial has some coverage of order of operations.

All that I can give you that's not horribly well-known is that and takes precedence over or.

If it helps to remember: In boolean algebra, and is represented like multiplication. Or is represented like addition. Those two operators work exactly the same as their boolean counterparts when you're using ones and zeroes for true and false, so it's easy to remember. Yes, 1 + 1 = 1. Deal with it.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Order of Operations | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.010 seconds.