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

#1 2010-12-05 15:47:25

bradtank44
New Scratcher
Registered: 2010-11-21
Posts: 2

Math help, ignoreing remainders

Hey all! I am doing a school project on computer programing, and using scratch as a visual aid. I am trying to transfer the program HiLo from HICCUP to scratch ( It can be found here here ) And for it to work right,i have to ignore remainders after devision. I have tried subtracting the MOD from it, but it seems to not work. The program is hereif you want to dissect it and tell me whats wrong. I am rather new to this, so sorry if there is a fairly obvious response!

Offline

 

#2 2010-12-06 06:38:25

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Math help, ignoreing remainders

bradtank44 wrote:

Hey all! I am doing a school project on computer programing, and using scratch as a visual aid. I am trying to transfer the program HiLo from HICCUP to scratch ( It can be found here here ) And for it to work right,i have to ignore remainders after devision. I have tried subtracting the MOD from it, but it seems to not work. The program is hereif you want to dissect it and tell me whats wrong. I am rather new to this, so sorry if there is a fairly obvious response!

Hmmm...
Remainder as in 1.3333?
If so, try this.
[blocks]
          <round(  ((  <{ No. }> <-> 0.5  ))   ))
[/blocks]

Hope that helps.

Last edited by markyparky56 (2010-12-06 06:44:26)


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#3 2010-12-06 07:32:43

mathematics
Scratcher
Registered: 2009-03-01
Posts: 1000+

Re: Math help, ignoreing remainders

There are 3 methods.

1. Check if the dividend is an odd number. If yes, minus 0.5 from the result.
[blocks]<set{ quotient }to( (( <{ dividend }> </> 2 ))
<if> <( (( <{ dividend }> <mod> 2 )) <=> 1 )>
<change{ quotient }by( -0.5
<end>[/blocks]

2. Use this script:
[blocks]<round( (( (( <{ dividend }> </> 2 )) <-> (( (( <{ dividend }> <mod> 2 )) </> 2 )) ))[/blocks]

3. Use the script provided by markyparky56. (Just in case you don't know, the <{ No. }>[/blocks] is the quotient.

Note: All of these methods are assuming <{ divisor }>[/blocks] = 2.

Last edited by mathematics (2010-12-06 07:41:05)

Offline

 

#4 2011-01-25 17:13:25

bradtank44
New Scratcher
Registered: 2010-11-21
Posts: 2

Re: Math help, ignoreing remainders

Sorry I haven't replied. Been busy, I never got to mess with your suggestions, but it all worked out anyway.You should be able to see the finished product on my profile. Thanks!

Offline

 

Board footer