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

#1 2012-02-18 10:24:20

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Mod Command

I'm working on adding the mod command to my calculator, but I don't know where it fits in the Order of Operations. Does anyone know? Thanks.  smile

Offline

 

#2 2012-02-18 11:52:58

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Mod Command

CheeseMunchy wrote:

When I receive [mod button hit]
set (theanswer) to <(1st number) mod (2nd number)>
?

Not exactly what I meant  tongue

I mean where it comes in the Order of Operations:

Parentheses (Including Sine Cosine Tangent etc.)
Square Roots and Exponents
Multiplacation/Division
Addition/Subtraction

Offline

 

#3 2012-02-18 12:16:20

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Mod Command

According to most sources I found on Google, in most languages, such as C-based ones, % (mod or modulo) takes the same precedence as multiplication and division.  However, there are always exceptions, so you should test it to make sure.   smile

Offline

 

#4 2012-02-18 12:28:13

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Mod Command

Greenatic wrote:

According to most sources I found on Google, in most languages, such as C-based ones, % (mod or modulo) takes the same precedence as multiplication and division.  However, there are always exceptions, so you should test it to make sure.   smile

Ok thanks!  smile

Offline

 

#5 2012-02-18 12:40:55

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Mod Command

laptop97 wrote:

Greenatic wrote:

According to most sources I found on Google, in most languages, such as C-based ones, % (mod or modulo) takes the same precedence as multiplication and division.  However, there are always exceptions, so you should test it to make sure.   smile

Ok thanks!  smile

No problem!  Glad I could help!  smile

Offline

 

#6 2012-02-19 19:55:09

360-International
Scratcher
Registered: 2011-07-17
Posts: 100+

Re: Mod Command

Remember that the modular function is a type of division.


https://lh4.googleusercontent.com/Oib6kyze-OrCFIRlqL6HYnWuHBQp1GfFoh5CkBlZGe3_9WCk-_DDwgfFrnD_mxJ_x2b18hMUyV2KVtIDiLdebyWaQQ6fbpKpZs-8auVep1zoSgOv-iA

Offline

 

#7 2012-02-20 07:08:13

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Mod Command

I'd assume it is the same as division, its parent.  hmm

Offline

 

#8 2012-02-20 08:00:27

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Mod Command

It comes after division -- because it returns the remainder of the division operation itself.

Last edited by rdococ (2012-02-20 08:00:46)

Offline

 

#9 2012-02-20 16:25:33

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Mod Command

Thanks everyone  smile

Offline

 

#10 2012-02-20 16:40:44

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: Mod Command

Closed by request.


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

Board footer