Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   roundup to 60 or 70 or 50 (http://www.velocityreviews.com/forums/t883550-roundup-to-60-or-70-or-50-a.html)

roundup to 60 or 70 or 50

This is probably an easy question but i'm in it so deep that i totally

I get the number 61;
I need to know the nearest decimal up. So I need to know 70.

how do I do that?

I'm totally stuck.

Re: roundup to 60 or 70 or 50

> I get the number 61;
> I need to know the nearest decimal up. So I need to know 70.

\$roundup = \$num % 10 ? \$num - \$num % 10 + 10 : \$num;

--
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 Randal L. Schwartz 11-09-2003 05:58 PM

Re: roundup to 60 or 70 or 50

>>>>> "Antoine" == Antoine Adams <antoine@nebula.nl> writes:

Antoine> I get the number 61;
Antoine> I need to know the nearest decimal up. So I need to know 70.

I usually cheat with something like 10*int((\$num+9)/10), if I know
they're all integers.

print "Just another Perl hacker,"

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Re: roundup to 60 or 70 or 50 (offtopic)

> print "Just another Perl hacker,"

Ok ok.. thx guys.

3 solutions and all three work..
I liked them all and tested them all

Thx thx thx thx

Now I can continue playing with GD::Graph and mysql data uotput sorting :-)

----
A G-string fits better then a perl string

 All times are GMT. The time now is 12:59 AM.