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

#1 2008-08-26 12:25:59

occulemens
Scratcher
Registered: 2008-08-26
Posts: 3

Is there any way to always round down?

I have a variable that divides by 10. So, say I have 75, divided by 10=7.5. I want to turn it into a whole number without making it round up. So if I have 7.9, I want it to round to 7. 2.5 rounding to 2, 5.7 to 5, etc.

Any ideas?

Offline

 

#2 2008-08-26 12:48:01

bigB
Scratcher
Registered: 2007-06-09
Posts: 100+

Re: Is there any way to always round down?

that would be called finding the integer value.  its a shame there isnt an interger function on scratch but there is a technique you can use.
use the round function on the number minus 0.5.  so for 5.7 try: round(5.7-0.5)  this becomes 5.2 which rounds down.
hope this helps.


http://scratch.mit.edu/projects/bigB/260981 Draw to Text
http://scratch.mit.edu/projects/bigB/181829 3D Stunt Flyer

Offline

 

#3 2008-08-26 12:53:34

occulemens
Scratcher
Registered: 2008-08-26
Posts: 3

Re: Is there any way to always round down?

bigB wrote:

that would be called finding the integer value.  its a shame there isnt an interger function on scratch but there is a technique you can use.
use the round function on the number minus 0.5.  so for 5.7 try: round(5.7-0.5)  this becomes 5.2 which rounds down.
hope this helps.

Thank you so much!

Offline

 

Board footer