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)
Offline
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)
Offline
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 ^_^
Offline
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
To be honest, I've never even seen these blocks before.
Offline
The <abs( [/blocks]block doesn't actually exist in scratch anymore, it's a function inside the trig block.
Offline
3rd grade -_-
Offline
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.
Offline