This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-02-25 14:01:30

pkeenan
Scratcher
Registered: 2007-09-14
Posts: 7

Order of operations

Scratch doesn't seem to follow the order of operations. For example:
set answer to 5*4+12/3 gives 40
You should multiply 5*4 and get 20, then divide 12/3 and get 4, and then add 20 + 4 and get 24

Offline

 

#2 2009-02-25 14:37:51

Ssbrawl700
Scratcher
Registered: 2009-02-11
Posts: 100+

Re: Order of operations

well personally if it did it in order of ops then it wouldn't be more user friendly.

Also if you put it like this

(( (( 5 <*> 4 )) <+> ((  12</> 3 )) ))

it is 24


Can you beat the ever-so challenging Keyboard Khaos?

Offline

 

#3 2009-02-25 14:46:22

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: Order of operations

It all depends on which blocks are in which, the ones that are furthest in go first.


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#4 2009-03-11 11:31:30

sallie
Scratcher
Registered: 2008-10-29
Posts: 1

Re: Order of operations

great

Offline

 

#5 2009-03-11 11:52:25

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

Re: Order of operations

Yeah, you just have to keep in mind that each one of those rounded arithmetic blocks is essentially a pair of parentheses, so you'll be forcing the order of operations each time you build a statement.

Offline

 

Board footer