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

#1 2012-08-21 16:59:40

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

int Block in Scratch

For those of you who dont know what int does then it rounds a number down to it's nearest lower whole number. Could we have this as a block in Scratch?

Offline

 

#2 2012-08-21 17:10:23

ftf841
Scratcher
Registered: 2012-02-19
Posts: 1000+

Re: int Block in Scratch

can be worked around


http://mag.racked.eu/cimage/i9002/Achievement++get%21/Hi+there./mca.png
http://mag.racked.eu/mcimage/i354/Achievement++get%21/CAKE%21%21%21%21%21/mca.png

Offline

 

#3 2012-08-21 17:13:15

thebriculator
Scratcher
Registered: 2011-07-11
Posts: 500+

Re: int Block in Scratch

exactly

(round((var)-(0.5)))
and for round-up:
(round((var)+(0.49999999999999999)))


.     http://tiny.cc/2cwgpw    http://tiny.cc/viwgpw    http://tiny.cc/iwwgpw

Offline

 

#4 2012-08-22 02:12:30

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: int Block in Scratch

thebriculator wrote:

exactly

(round((var)-(0.5)))
and for round-up:
(round((var)+(0.49999999999999999)))

Thank you!

Offline

 

#5 2012-08-22 02:16:15

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: int Block in Scratch

JH1010 wrote:

thebriculator wrote:

exactly

(round((var)-(0.5)))
and for round-up:
(round((var)+(0.49999999999999999)))

Thank you!

You don't need the .99999, 5 is fine


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#6 2012-08-22 02:34:47

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: int Block in Scratch

zammer990 wrote:

JH1010 wrote:

thebriculator wrote:

exactly

(round((var)-(0.5)))
and for round-up:
(round((var)+(0.49999999999999999)))

Thank you!

You don't need the .99999, 5 is fine

Int only rounds down anyway.

Offline

 

#7 2012-08-22 05:22:19

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: int Block in Scratch

zammer990 wrote:

JH1010 wrote:

thebriculator wrote:

exactly

(round((var)-(0.5)))
and for round-up:
(round((var)+(0.49999999999999999)))

Thank you!

You don't need the .99999, 5 is fine

No, if var is a whole number it will add .5 and round up to the number above.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#8 2012-08-22 05:38:52

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: int Block in Scratch

joefarebrother wrote:

zammer990 wrote:

JH1010 wrote:


Thank you!

You don't need the .99999, 5 is fine

No, if var is a whole number it will add .5 and round up to the number above.

True.

Offline

 

#9 2012-08-22 09:33:53

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: int Block in Scratch

A better way is to X - X mod 1, but this needs the input twice.


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#10 2012-08-22 11:43:52

thebriculator
Scratcher
Registered: 2011-07-11
Posts: 500+

Re: int Block in Scratch

Yep, round up needs the .999999999
and cool, the mod technique works for "round-up"


.     http://tiny.cc/2cwgpw    http://tiny.cc/viwgpw    http://tiny.cc/iwwgpw

Offline

 

Board footer