File Coverage

lib/Spreadsheet/Engine/Function/ODD.pm
Criterion Covered Total %
statement 17 17 100.0
branch 6 6 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Spreadsheet::Engine::Function::ODD;
2              
3 28     28   154 use strict;
  28         59  
  28         1033  
4 28     28   154 use warnings;
  28         58  
  28         772  
5              
6 28     28   155 use base 'Spreadsheet::Engine::Fn::math';
  28         66  
  28         5492  
7              
8             sub calculate {
9 203     203 1 6478 my ($self, $value) = @_;
10 203 100       721 my $result = $value < 0 ? -$value : $value;
11 203         453 my $extra = $result - int($result);
12 203 100       494 if ($extra) {
13 56         200 $result = int($result + 1) + (1 - (($result + 1) % 2));
14             } else { # integer
15 147         434 $result = $result + (1 - ($result % 2));
16             }
17 203 100       574 $result = -$result if $value < 0;
18 203         4732 return $result;
19             }
20              
21             1;
22              
23             __END__