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

#1 2009-08-24 20:49:10

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Removing a decimal

Hi! I'm creating a project where I won't to remove the decimal from a number (but I do NOT want to round it). Say I have a number that is 4.9, I would like it to read 4. I have tried several formulas with little success. I know in some languages you can use the int() function. I don't think Scratch has that (or am I missing something)?

Offline

 

#2 2009-08-24 21:09:45

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

Re: Removing a decimal

Heh heh...

Code:

[set [NUM] to (round (YOURNUM))]
[if ((NUM) > (YOURNUM))]
[change [NUM] by (-1)]

That should help.

Last edited by The-Whiz (2009-08-24 21:10:02)

Offline

 

#3 2009-08-24 21:20:30

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Removing a decimal

Thanks. :-0

I was trying all of the stuff with mod, and I didn't realize it was that simple. Still, Scratch should have an int() function.

Last edited by shadow_7283 (2009-08-24 21:23:31)

Offline

 

#4 2009-08-24 22:08:20

illusionist
Retired Community Moderator
Registered: 2008-07-02
Posts: 1000+

Re: Removing a decimal

Your right. We also need a ( ) ^ ( ) block.


http://i.imgur.com/8LX1NrV.png

Offline

 

Board footer