Page 1 of 1

How to round up to nearest whole number

Posted: Tue Nov 20, 2012 11:47 am
by louisharrodine
Hi there,

I'm dealing with various decimal numbers:

4.6736583758
28.01392764

etc


How would I round numbers such as these up to the nearest whole number? thanks

Re: How to round up to nearest whole number

Posted: Tue Nov 20, 2012 12:07 pm
by Klaus
Hi Louis,

you'll be surprised (NOT):
put round(4.6736583758) -> 5
put round(28.01392764) -> 28
:D

Check the dictionary for more options of "round"...


Best

Klaus

Re: How to round up to nearest whole number

Posted: Tue Nov 20, 2012 3:14 pm
by dunbarx
Hi.

One way to always round to the next highest integer is to;

Code: Select all

on mouseup
   answer roundUp(msg)
end mouseup

function roundUp var
   return round(var + 0.5)
end roundUp
Craig Newman