Re: Round Handler, care to share.
Re: Round Handler, care to share.
- Subject: Re: Round Handler, care to share.
- From: Nigel Garvey <email@hidden>
- Date: Thu, 7 Dec 2000 12:14:01 +0000
"Bourque, Jason" wrote on Wed, 6 Dec 2000 15:35:23 -0500:
>
Hello,
>
>
Does anyone have a vanilla handler that finds the next rounded value of a
>
number, this is to be used in charts.
>
>
i.e. 17.2 rounded would be 20
>
>
22.8 rounded would be 25
It was fascinating to see all the different replies to this. Has everyone
else been working on alternatives to 'round' as well?
Reviews:
Carl's: Rounds up numbers that are already multiples of 5, doesn't work
with negatives. (But then that wasn't a stipulation.)
Arthur's: Ditto. Begins to lag behind on numbers greater than about
25....
WRATH1's: Very effective on all counts.
Marc's: Dodgy use of floating-point resolution. Doesn't work with
negatives.
Mine: Rounds away from zero when 'up' would perhaps be more
appropriate. Easily cured by removing the middle line (and changing the
handler's name!)
NG