roundup to 60 or 70 or 50

Discussion in 'Perl Misc' started by Antoine Adams, Nov 9, 2003.

  1. 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.
    Antoine Adams, Nov 9, 2003
    #1
    1. Advertising

  2. 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
    Gunnar Hjalmarsson, Nov 9, 2003
    #2
    1. Advertising

  3. >>>>> "Antoine" == Antoine Adams <> 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
    <> <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!
    Randal L. Schwartz, Nov 9, 2003
    #3
  4. 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
    Antoine Adams, Nov 10, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Donald 'Paddy' McCarthy

    Can Roundup do this...

    Donald 'Paddy' McCarthy, Oct 10, 2003, in forum: Python
    Replies:
    3
    Views:
    378
    Paddy McCarthy
    Oct 15, 2003
  2. richard
    Replies:
    0
    Views:
    295
    richard
    May 17, 2004
  3. Richard Jones

    Roundup Issue Tracker release 1.1.1

    Richard Jones, Mar 3, 2006, in forum: Python
    Replies:
    0
    Views:
    485
    Richard Jones
    Mar 3, 2006
  4. george williams

    Re: Roundup Issue Tracker release 1.1.1

    george williams, Mar 3, 2006, in forum: Python
    Replies:
    0
    Views:
    433
    george williams
    Mar 3, 2006
  5. Richard Jones
    Replies:
    0
    Views:
    516
    Richard Jones
    Mar 14, 2009
Loading...

Share This Page