On May 18, John Storms said:
>Not the best code, but it works fine.
>
># roundup(<number>,[<number of digits past decimal to return>]);
># returns a truncated and rounded up value.
>sub roundup {
> my($i); for($i=0;$i<length($num);$i++) {
> $char = substr($num,$i,1);
> $next = substr($num,$i+1,1);
Rounding numbers shouldn't be a string operation, and this only slows
things down. When you learn rounding in math class, you learn it working
with numbers -- you can apply the logic to Perl (as seen in my response).
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
*** I need a publisher for my book "Learning Perl Regular Expressions" ***