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

#1 2012-12-22 21:38:43

dariusz1221
New Scratcher
Registered: 2012-12-16
Posts: 8

round script

is there a way to change the round number to the tenths place?

Offline

 

#2 2012-12-22 23:28:04

mrn0body
Scratcher
Registered: 2012-12-11
Posts: 37

Re: round script

What do you mean?


Why Fit In When You Were Born To Stand Out

Offline

 

#3 2012-12-23 02:07:26

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: round script

dariusz1221 wrote:

is there a way to change the round number to the tenths place?

This will round off to the nearest tenths:

set [number v] to <THE NUMBER YOU WANT>
set [var num v] to (((number) - ((number) mod (10))) / (10))
change [var num v] by ((number) mod (10))
set [var num v] to (round (var num))
I didn't want to overcomplicate the script and give myself a headache, so there.

Last edited by jontmy00 (2012-12-23 02:08:16)


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#4 2012-12-23 08:50:49

dariusz1221
New Scratcher
Registered: 2012-12-16
Posts: 8

Re: round script

so a sprite rounds up to the nearest tenths place

Offline

 

#5 2012-12-23 09:05:28

dariusz1221
New Scratcher
Registered: 2012-12-16
Posts: 8

Re: round script

jontmy00 will this work if i put in a 5 to round to the nearest 5? so like if it 11 will it round to 10 but if sprite gets 13 it will round to 15? i tried 10 and that was 2 far off for my liking.

Offline

 

#6 2012-12-23 09:09:21

dariusz1221
New Scratcher
Registered: 2012-12-16
Posts: 8

Re: round script

maybe i should explain a bit more what im trying to do. i want the user to move some sprites around and if they get with in 5x or 5y position to broadcast.

Offline

 

Board footer