C.R. wrote: > Does anyone have a routine that will round an integer to a multiple of > 5? > > For example: if number ends in 0 or 5, no rounding is done. > If number ends in 1,2 the ones place rounds down to 0. > If number ends in 3,4 the ones place rounds up to 5. > If number ends in 6,7 the ones place rounds down to 5. > If number ends in 8,9 the ones places rounds up to 0 and tens places > goes up by 1.
$ perl -le' for my $num ( 1600 .. 1630 ) { print $num, "\t", int( ( $num + 2 ) / 5 ) * 5 } ' 1600 1600 1601 1600 1602 1600 1603 1605 1604 1605 1605 1605 1606 1605 1607 1605 1608 1610 1609 1610 1610 1610 1611 1610 1612 1610 1613 1615 1614 1615 1615 1615 1616 1615 1617 1615 1618 1620 1619 1620 1620 1620 1621 1620 1622 1620 1623 1625 1624 1625 1625 1625 1626 1625 1627 1625 1628 1630 1629 1630 1630 1630 John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>