File Coverage

blib/lib/Math/NumSeq/Base/Digits.pm
Criterion Covered Total %
statement 37 39 94.8
branch n/a
condition 1 3 33.3
subroutine 13 14 92.8
pod 2 3 66.6
total 53 59 89.8


line stmt bran cond sub pod time code
1             # Copyright 2010, 2011, 2012, 2013, 2014 Kevin Ryde
2              
3             # This file is part of Math-NumSeq.
4             #
5             # Math-NumSeq is free software; you can redistribute it and/or modify
6             # it under the terms of the GNU General Public License as published by the
7             # Free Software Foundation; either version 3, or (at your option) any later
8             # version.
9             #
10             # Math-NumSeq is distributed in the hope that it will be useful, but
11             # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12             # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13             # for more details.
14             #
15             # You should have received a copy of the GNU General Public License along
16             # with Math-NumSeq. If not, see .
17              
18             package Math::NumSeq::Base::Digits;
19 15     15   287 use 5.004;
  15         48  
  15         555  
20 15     15   77 use strict;
  15         21  
  15         466  
21              
22 15     15   69 use vars '$VERSION', '@ISA', '@EXPORT_OK';
  15         24  
  15         959  
23             $VERSION = 71;
24              
25 15     15   71 use Exporter;
  15         25  
  15         615  
26 15     15   77 use Math::NumSeq;
  15         30  
  15         1230  
27             @ISA = ('Math::NumSeq', 'Exporter');
28             @EXPORT_OK = ('parameter_info_array');
29              
30             sub characteristic_digits {
31 8     8 0 19 my ($self) = @_;
32 8         34 return $self->{'radix'};
33             }
34 15     15   71 use constant characteristic_increasing => 0;
  15         38  
  15         862  
35             # use constant characteristic_non_decreasing => 0;
36 15     15   167 use constant characteristic_smaller => 1;
  15         29  
  15         613  
37 15     15   81 use constant characteristic_integer => 1;
  15         35  
  15         592  
38 15     15   71 use constant values_min => 0;
  15         28  
  15         1621  
39             sub values_max {
40 0     0 1 0 my ($self) = @_;
41 0         0 return $self->{'radix'} - 1;
42             }
43              
44 15         60 use constant parameter_common_radix =>
45             { name => 'radix',
46             type => 'integer',
47             display => Math::NumSeq::__('Radix'),
48             default => 10,
49             minimum => 2,
50             width => 3,
51             description => Math::NumSeq::__('Radix, ie. base, for the values calculation. Default is decimal (base 10).'),
52 15     15   77 };
  15         24  
53 15     15   72 use constant parameter_info_array => [ parameter_common_radix() ];
  15         30  
  15         2176  
54              
55             sub pred {
56 104     104 1 542 my ($self, $value) = @_;
57 104   33     708 return ($value == int($value)
58             && $value >= 0
59             && $value < $self->{'radix'});
60             }
61              
62             1;
63             __END__