Re: Rounding numbers up
Re: Rounding numbers up
- Subject: Re: Rounding numbers up
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 15 Mar 2001 23:19:31 -0800
On 3/16/01 6:52 AM, "Edmond Cho" <email@hidden> wrote:
>
I remember seeing a method to do this, but have been unable to find any
>
reference to rounding numbers in the Language Guide.
>
>
The calculation I am after is not strictly rounding to the nearest integer
>
but rounding UP to the next whole number.
>
>
1.6 ---> 2
>
2.1 ---> 3
>
1.4 ---> 2
>
>
So, any remainder results in rounding up.
>
Any tips?
>
It's not in the ASLG because it's a scripting addition. Check the Standard
Additions dictionary for 'round'. (If you're dealing with positive numbers,
then) 'rounding up' parameter is what you want.
OS 9/1 version (adds that final parameter "as taught in school):
round : Round number to integer
round [ real] -- the number to round
[rounding up/down/toward zero/to nearest/as taught in school] -- the
rounding direction; if omitted, rounds to nearest. 3to nearest2 rounds .5
cases to the nearest even integer in order to decrease cumulative errors.
To always round .5 away from zero, use 3as taught in school.2
Result : integer -- the rounded value
--
Paul Berkowitz