Yes, I am proposing a Perl module for rounding numbers, to be called
Math::Round.  This may seem like an odd thing to suggest, but rounding
numbers can be a little tricky, and I have sometimes found myself wishing
for functions like these.  The module would include the following
functions:

round: round to nearest integer; numbers ending in .5 go "to infinity" (3.5 becomes 4, 
-3.5 becomes -4)
round_even: round; numbers ending in .5 go to the even number
round_odd: round to the odd number
round_rand: round up or down randomly
nearest: round to the nearest multiple of any number; e.g., nearest(20, 36) yields 40
nearest_rand: like nearest, up or down randomly; e.g., nearest(10, 35) may yield 30 or 
40

Comments?

Reply via email to