Can anyone make an int() function for Scratch? Preferably, it would be part of the
( [abs^] of () ). I am really frustrated when I want to get rid of those decimals and have to create another variable and a few extra blocks of code to do it! THANKS!
Offline
Offline
Just use the round block. AND HAVE YOU SEEN http://scratch.mit.edu/projects/bharvey/995971????????????
Offline
The [block]<round( [/block] will work
Last edited by ThePCKid (2010-04-19 20:51:33)
Offline
Guys, round will not work. round(2.5) is 3, but int(2.5) is 2.
Here's a little lambda/function/whatever
int(x) = x - (x mod 1)
EDIT: I'm not sure about negative numbers, though.
Last edited by nXIII (2010-04-19 21:41:57)
Offline
What about something like this:
Iv tested it, took me a while to work it out, but it works.
Last edited by markyparky56 (2010-04-20 14:47:32)
Offline
That works, but there is a simpler way, and it is not convient.
As for everyone else, like nxIII explained, there is a difference between int() and round(). Int stands for integer, which basically takes away any decimal points.
Thanks nxIII, for the most helpful answer. I wish this was a block in Scratch though.
Offline