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

#1 2009-12-29 13:58:02

iamrpk
Scratcher
Registered: 2009-04-06
Posts: 1000+

How do you use these blocks...

How do you use these blocks?:

((  <mod>  ))
<abs( )>
<round( )>

Last edited by iamrpk (2009-12-29 13:58:39)


http://www.punbb-hosting.com/forums/AwesomeBooks911Forum/index.php

Offline

 

#2 2009-12-29 14:38:26

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How do you use these blocks...

Round is rounding a number to the closest integer.
For example,


<round( 1.1

Would be 1 because the integer closest to 1.1 is 1.

((  <mod>  ))

Is the remainder of dividing the two numbers you type in.

<abs(
Is basically the number without any sign in front of it.
<abs( 2
is 2
<abs( -2
is 2

Really, if it's a positive number, nothing will change. If what you typed in is a negative number, then your result will be that number without the negative sign.

What grade are you in?
(don't answer if you don't want to, but I think most people on scratch should have learned this in school already)

Last edited by juststickman (2009-12-29 14:38:38)


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#3 2009-12-29 15:07:36

WeirdF
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How do you use these blocks...

I'll explain the maths of it, justtestingstickman only explained what they do, I'll also give examples.

Round:
I assume you know how to round whole numbers, like to the nearest multiple of 10, like 77 to the nearest multiple of 10 is 80, and if it's half way between two multiples of 10, you round it up.. But if you want to round to a whole number, then it's pretty much the same. Take the number justtestingstickman used, 1.1, look at the number after the decimal point, it is nearest to 0, rather than 10, so 'round (1.1)' would be 1, and 'round (1.6)' would be 2. If you have a number like 1.45, then just check whether it is under half way between 1 and 2, by checking the first number after the decimal place.

This could be useful if you had a score variable, and the script went something like this:

if action that increases score is happening
change score by 0.1

The at the end you could round the score. It's also useful if you want to round the timer.

Mod:
This is basically the remainder of 2 numbers. 20 divided by 6 is 3 remainder 2, so
'(20) mod (6) would be 2.

A way to use this is if you had a maths test project, and one of the questions was 'Enter a multiple of 5', then you could do this:

if answer mod 5 = 0
broadcast 'Correct answer'

Abs:
Abs means 'Absolute Number', basically, the abs of -5 is 5, and the Abs of 5 is 5. So it is always the whole number of itself, if it isn't a whole number already. #

The main use of Abs is in scrolling, where you would use the script:

When green flag pressed
forever
if Abs of x position > 454
hide
else show

Which is a necessary script to make sprites hide or show depending on whether they're supposed to be there or not.

I hope that hopes.

Last edited by WeirdF (2009-12-29 15:10:12)


http://i.cr3ation.co.uk/dl/s1/gif/847032b8a331def77529b6a0384db1fe_handfingers.gif

Offline

 

#4 2009-12-29 16:36:20

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: How do you use these blocks...

I think a simple definition for abs is "distance from zero"...


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#5 2009-12-30 05:42:19

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How do you use these blocks...

Chrischb wrote:

I think a simple definition for abs is "distance from zero"...

Yup. that's it!

I was half asleep when I posted the explanation so I only included what they do ^_^


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#6 2009-12-30 11:10:27

WeirdF
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How do you use these blocks...

Chrischb wrote:

I think a simple definition for abs is "distance from zero"...

That's a good way to explain it! I never thought of that.


http://i.cr3ation.co.uk/dl/s1/gif/847032b8a331def77529b6a0384db1fe_handfingers.gif

Offline

 

#7 2010-03-19 09:19:37

sevrin2
Scratcher
Registered: 2008-03-01
Posts: 1

Re: How do you use these blocks...

WeirdF wrote:

Chrischb wrote:

I think a simple definition for abs is "distance from zero"...

That's a good way to explain it! I never thought of that.

abs=absolute number.<abs(-7=7

Offline

 

#8 2010-03-19 10:24:44

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: How do you use these blocks...

sevrin2 wrote:

WeirdF wrote:

Chrischb wrote:

I think a simple definition for abs is "distance from zero"...

That's a good way to explain it! I never thought of that.

abs=absolute number.<abs(-7=7

Don't bump topics, please. This topic had been inactive for over 3 months...

Offline

 

#9 2010-03-19 11:55:37

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: How do you use these blocks...

To be honest, I've never even seen these blocks before.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#10 2010-03-19 13:03:12

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: How do you use these blocks...

The <abs( [/blocks]block doesn't actually exist in scratch anymore, it's a function inside the trig block.


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#11 2010-03-19 15:58:28

shamrocker
Scratcher
Registered: 2009-03-19
Posts: 1000+

Re: How do you use these blocks...

3rd grade -_-


http://i46.tinypic.com/2s1b32e.png
respect the oxford comma

Offline

 

#12 2010-03-19 20:47:47

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: How do you use these blocks...

The-Whiz wrote:

sevrin2 wrote:

WeirdF wrote:

That's a good way to explain it! I never thought of that.

abs=absolute number.<abs(-7=7

Don't bump topics, please. This topic had been inactive for over 3 months...

Is it correct that "bumping" a topic is "*bringing it back to life* after it had been inactive for awhile"?

Is it better to start a whole new topic (on the same subject that was previously talked about)?
          Might we not end up with dozens of discussions of the same thing?  (Instead of one place to find the discussion of a topic?)

So if we search old topics looking for info and have a question, we should just let them lie and start new ones? 

(And is this official Scratch Forum policy, or individual preference?)

Thanks.   smile

Offline

 

Board footer