Velocity Reviews

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)

Antoine Adams 11-09-2003 01:23 PM

roundup to 60 or 70 or 50
 
This is probably an easy question but i'm in it so deep that i totally
do not see the answer.

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.

Gunnar Hjalmarsson 11-09-2003 01:25 PM

Re: roundup to 60 or 70 or 50
 
Antoine Adams wrote:
> 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;

--
Gunnar Hjalmarsson
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!

Antoine Adams 11-10-2003 09:17 PM

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 01:51 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57