Just another Perl shrine | |
PerlMonks |
Re: Rounding to the nearest 50by Crian (Curate) |
on Mar 01, 2004 at 14:51 UTC ( [id://332930]=note: print w/replies, xml ) | Need Help?? |
First of all, you are not looking for the nearest value. What you need is a customised ceil (see perldoc POSIX).
In such cases, where you want to look for the "nearest but not smaller then" and your step is not 1, but X (X = 50 in your case), you can do the following:
with the result
Edit: Sorry, I was interrupted while writing this answer, when I started writing, there was no comparable posted.
In Section
Seekers of Perl Wisdom
|
|