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

#1 2012-02-07 16:04:40

mitchboy
Scratcher
Registered: 2011-11-29
Posts: 59

"Round to" block

I think it would be cool to have a block that instead of always rounding to the nearest one, it could round to the nearest 10, 100, etc. It would look like this:

round (5) to nearest (10)
or this:
round (5) to nearest [ten v]
This could be useful for making games that involve placing buildings in a city, a level creator like Mario, word searches, and more. It could be used for rounding the mouse x or y or another sprite's x or y to go there or point there. I think it would be very useful. Don't you think?
Supporters (16):

mitchboy
Clank23
Lucario621
scimonster
veggieman001
K-Jam
PencilFactory
Haiming
muppetds
JabberJay
turkey3
ImagineIt
TorbyFork234
Daroach1
360-International
James07

Last edited by mitchboy (2012-04-07 11:19:18)


Quote of the week: "I am NOT being DRAMATIC!" ~Looney Tunes
Check out my newest game here!

Offline

 

#2 2012-02-07 16:23:05

Clank23
Scratcher
Registered: 2011-03-01
Posts: 1000+

Re: "Round to" block

I like this idea


http://img846.imageshack.us/img846/4333/signaturely.png

Offline

 

#3 2012-02-07 19:13:54

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: "Round to" block

There is already a way to do it. Heres how:

round (5/10 * 10)

Last edited by bobbybee (2012-02-07 19:33:08)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#4 2012-02-07 20:08:30

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: "Round to" block

bobbybee wrote:

There is already a way to do it. Heres how:

round (5/10 * 10)

I'll try to clarify this...

Let's say I have a number, 17.283. I want to round it to the nearest tenth. So I do this:

set [number v] to ( (round ( (17.283) * (10) ) ) / (10) )
17.283 times 10 is 172.83, and 172.83 rounded is 173, and 173 divided by 10 is 17.3.

It continues for other places:

set [hundreds v] to ( (round ( (x) / (100) ) ) * (100) )
set [tens v] to ( (round ( (x) / (10) ) ) * (10) )
set [ones v] to (round (x))
set [tenth v] to ( (round ( (x) * (10) ) ) / (10) )
set [hundredth v] to ( (round ( (x) * (100) ) ) / (100) )
However, I agree, a block for rounding to specific places would be handy.  smile


http://i.imgur.com/WBkM2QQ.png

Offline

 

#5 2012-02-07 23:22:38

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

Re: "Round to" block

Thanks for the workaround Lucario; I was wondering how to do that.  smile
And I agree, it would be better to have a block. Also (round () [up/down v])

Offline

 

#6 2012-02-07 23:52:08

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: "Round to" block

scimonster wrote:

Thanks for the workaround Lucario; I was wondering how to do that.  smile
And I agree, it would be better to have a block. Also (round () [up/down v])

Add 0.5/0.05/0.005 before rounding to round up, subtract 0.5/0.05/0.005 before rounding to round down.


http://trinary.tk/images/signature_.php

Offline

 

#7 2012-02-08 00:30:36

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

Re: "Round to" block

trinary wrote:

scimonster wrote:

Thanks for the workaround Lucario; I was wondering how to do that.  smile
And I agree, it would be better to have a block. Also (round () [up/down v])

Add 0.5/0.05/0.005 before rounding to round up, subtract 0.5/0.05/0.005 before rounding to round down.

Yeah, I found that out already too, but still, a block might be useful.

Offline

 

#8 2012-02-08 00:57:15

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: "Round to" block

I support. They should add these blocks as well:

floor ()
ceil ()


Posts: 20000 - Show all posts

Offline

 

#9 2012-02-08 01:37:07

K-Jam
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: "Round to" block

that would be useful if you wanted something to snap to a grid or something


http://images.inmagine.com/img/imagezoo/iz162/Iz162012.jpg COMPASS!!!

Offline

 

#10 2012-02-08 10:27:00

mitchboy
Scratcher
Registered: 2011-11-29
Posts: 59

Re: "Round to" block

Thanks Clank23, Lucario621, scimonster, veggieman001, and K-Jam for supporting.

Last edited by mitchboy (2012-02-22 15:42:02)


Quote of the week: "I am NOT being DRAMATIC!" ~Looney Tunes
Check out my newest game here!

Offline

 

#11 2012-02-08 10:55:54

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: "Round to" block

veggieman001 wrote:

I support. They should add these blocks as well:

floor ()
ceil ()

That can be done already  wink  For floor, it's

(round((Number)-[0.5]))
and for ceiling it's
(round((Number)+[0.5]))

Last edited by RedRocker227 (2012-02-08 10:56:12)


Why

Offline

 

#12 2012-02-08 11:10:16

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: "Round to" block

But there should be separate blocks for it anyway!


Posts: 20000 - Show all posts

Offline

 

#13 2012-02-08 11:26:13

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: "Round to" block

Ehh, I guess it would be more convenient. I never need to use those functions anyway though.

Last edited by RedRocker227 (2012-02-08 11:26:22)


Why

Offline

 

#14 2012-02-08 11:28:37

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: "Round to" block

RedRocker227 wrote:

Ehh, I guess it would be more convenient. I never need to use those functions anyway though.

:3


Posts: 20000 - Show all posts

Offline

 

#15 2012-02-08 11:33:52

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: "Round to" block

veggieman001 wrote:

RedRocker227 wrote:

Ehh, I guess it would be more convenient. I never need to use those functions anyway though.

:3

I know what they are, silly :> I mean that the chances are, I'll never need to use either of them in my project :3


Why

Offline

 

#16 2012-02-08 11:37:48

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: "Round to" block

RedRocker227 wrote:

veggieman001 wrote:

RedRocker227 wrote:

Ehh, I guess it would be more convenient. I never need to use those functions anyway though.

:3

I know what they are, silly :> I mean that the chances are, I'll never need to use either of them in my project :3

Oh I know, but you can never be sure  wink


Posts: 20000 - Show all posts

Offline

 

#17 2012-02-08 12:37:13

Bklecka
Scratcher
Registered: 2011-08-27
Posts: 1000+

Re: "Round to" block

its is in the exparamental viewer
but they took that down


http://i48.tinypic.com/106ijc9.jpg

Offline

 

#18 2012-02-08 12:42:36

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: "Round to" block

you know why they're making BYOB?  big_smile

Offline

 

#19 2012-02-09 15:17:34

legoscratch
Scratcher
Registered: 2010-06-18
Posts: 100+

Re: "Round to" block

Bklecka wrote:

its is in the exparamental viewer
but they took that down

Really?  I don't see it. Click here and see if you can find it.


If you are having trouble with simple counting, use the following mnemonic device: 1 comes before 2 comes before 5,280 comes before 523,860,759 comes after the square root of -153 comes before π. This will make your previous counting problems seem like no big deal.

Offline

 

#20 2012-02-09 15:44:52

mitchboy
Scratcher
Registered: 2011-11-29
Posts: 59

Re: "Round to" block

legoscratch wrote:

Bklecka wrote:

its is in the exparamental viewer
but they took that down

Really?  I don't see it. Click here and see if you can find it.

That takes me to the home page for some reason.


Quote of the week: "I am NOT being DRAMATIC!" ~Looney Tunes
Check out my newest game here!

Offline

 

#21 2012-02-09 15:49:39

Bklecka
Scratcher
Registered: 2011-08-27
Posts: 1000+

Re: "Round to" block

Cause They Took The Viewer Down!
EDIT: you can still find it here http://scratch.mit.edu//static/experimental/Scratch.swf

Last edited by Bklecka (2012-02-09 15:52:33)


http://i48.tinypic.com/106ijc9.jpg

Offline

 

#22 2012-02-09 16:20:58

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: "Round to" block

veggieman001 wrote:

I support. They should add these blocks as well:

floor ()
ceil ()

Ooh that's a good idea. It is possible to do that right now, as shown below:

set [floor v] to (round ( (number) - (0.5) ))
set [ceil v] to (round ( (number) + (0.5) ))
But it's a bit of a hassle.


http://i.imgur.com/WBkM2QQ.png

Offline

 

#23 2012-02-09 18:25:54

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: "Round to" block

mitchboy wrote:

legoscratch wrote:

Bklecka wrote:

its is in the exparamental viewer
but they took that down

Really?  I don't see it. Click here and see if you can find it.

That takes me to the home page for some reason.

Yeah, me too. I'm on my iPod, so it may be something to do with that...


Why

Offline

 

#24 2012-02-09 18:34:45

legoscratch
Scratcher
Registered: 2010-06-18
Posts: 100+

Re: "Round to" block

mitchboy wrote:

legoscratch wrote:

Bklecka wrote:

its is in the exparamental viewer
but they took that down

Really?  I don't see it. Click here and see if you can find it.

That takes me to the home page for some reason.

Weird... it works for me.  Maybe it logs you out for some reason...?

Last edited by legoscratch (2012-02-09 18:34:55)


If you are having trouble with simple counting, use the following mnemonic device: 1 comes before 2 comes before 5,280 comes before 523,860,759 comes after the square root of -153 comes before π. This will make your previous counting problems seem like no big deal.

Offline

 

#25 2012-02-09 19:34:05

mitchboy
Scratcher
Registered: 2011-11-29
Posts: 59

Re: "Round to" block

legoscratch wrote:

mitchboy wrote:

legoscratch wrote:


Really?  I don't see it. Click here and see if you can find it.

That takes me to the home page for some reason.

Weird... it works for me.  Maybe it logs you out for some reason...?

I am using a Windows XP computer and it doesn't log me out. Some other people have reported this too. I've tried Chrome, Firefox, and IE, so it's not the browser.


Quote of the week: "I am NOT being DRAMATIC!" ~Looney Tunes
Check out my newest game here!

Offline

 

Board footer