roundup to 60 or 70 or 50

A

Antoine Adams

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.
 
G

Gunnar Hjalmarsson

Antoine said:
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;
 
R

Randal L. Schwartz

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,"
 
A

Antoine Adams

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top