in reply to Round up 3 values to the next 100

Are you very specific about solving this with regex?
Instead of using substring or regex, I feel this approach is more logical.
#!/usr/bin/perl -w use strict; my $num = 786603; my $rem = $num % 100; $num += (100 - $rem) if ($rem > 0); print $num."\n";

Replies are listed 'Best First'.
Re^2: Round up 3 values to the next 100
by Anonymous Monk on Sep 13, 2010 at 11:00 UTC
    Thanks - I'm using this in my code!

      Hi, how about this one?
      This is much more flexible by changing the value of $digit and simple in a one line.

      function roundup($number, $digit = 100) { return ( is_numeric($number) && is_numeric($ digit) ) ? (ceil($numbe +r/$ digit)*$digit) : false; }

      Please feel free to contact me at chae@azstrada.com if you have any questions.
      Chae from Seoul Korea.

        What language are you using? Does not seem to be Perl...