File Coverage

lib/Spreadsheet/Engine/Function/MOD.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 25 25 100.0


line stmt bran cond sub pod time code
1             package Spreadsheet::Engine::Function::MOD;
2              
3 28     28   156 use strict;
  28         55  
  28         939  
4 28     28   144 use warnings;
  28         58  
  28         756  
5              
6 28     28   262 use base 'Spreadsheet::Engine::Fn::math2';
  28         60  
  28         6512  
7              
8             sub calculate {
9 252     252 1 8850 my ($self, $x, $y) = @_;
10 252 100       910 die Spreadsheet::Engine::Error->div0 if $y == 0;
11 219         560 my $quotient = $x / $y;
12 219 100       552 if ($quotient >= 0) {
13 148         259 $quotient = int($quotient);
14             } else {
15 71         215 $quotient = int($quotient) - 1;
16             }
17 219         4909 return $x - ($quotient * $y);
18             }
19              
20             1;
21              
22             __END__