summaryrefslogtreecommitdiffstats
path: root/lib/MDK/Common
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MDK/Common')
-rw-r--r--lib/MDK/Common/Math.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/MDK/Common/Math.pm b/lib/MDK/Common/Math.pm
index 5ed9a61..c738f71 100644
--- a/lib/MDK/Common/Math.pm
+++ b/lib/MDK/Common/Math.pm
@@ -126,8 +126,8 @@ sub odd { $_[0] % 2 == 1 }
sub sqr { $_[0] * $_[0] }
sub sign { $_[0] <=> 0 }
sub round { int($_[0] + 0.5) }
-sub round_up { my ($i, $r) = @_; $i = int $i; $i += $r - ($i + $r - 1) % $r - 1 }
-sub round_down { my ($i, $r) = @_; $i = int $i; $i -= $i % $r }
+sub round_up { my ($i, $r) = @_; $r ||= 1; $i = int $i; $i += $r - ($i + $r - 1) % $r - 1 }
+sub round_down { my ($i, $r) = @_; $r ||= 1; $i = int $i; $i -= $i % $r }
sub divide { my $d = int $_[0] / $_[1]; wantarray() ? ($d, $_[0] % $_[1]) : $d }
sub min { my $n = shift; $_ < $n and $n = $_ foreach @_; $n }
sub max { my $n = shift; $_ > $n and $n = $_ foreach @_; $n }