File Coverage

blib/lib/Math/NumSeq/Base/Digits.pm
Criterion Covered Total %
statement 36 38 94.7
branch n/a
condition 1 3 33.3
subroutine 13 14 92.8
pod 2 3 66.6
total 52 58 89.6


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   222 use 5.004;
  15         33  
20 15     15   47 use strict;
  15         11  
  15         279  
21              
22 15     15   43 use vars '$VERSION', '@ISA', '@EXPORT_OK';
  15         15  
  15         718  
23             $VERSION = 72;
24              
25 15     15   55 use Exporter;
  15         19  
  15         437  
26 15     15   42 use Math::NumSeq;
  15         10  
  15         855  
27             @ISA = ('Math::NumSeq', 'Exporter');
28             @EXPORT_OK = ('parameter_info_array');
29              
30             sub characteristic_digits {
31 8     8 0 13 my ($self) = @_;
32 8         20 return $self->{'radix'};
33             }
34 15     15   49 use constant characteristic_increasing => 0;
  15         13  
  15         654  
35             # use constant characteristic_non_decreasing => 0;
36 15     15   49 use constant characteristic_smaller => 1;
  15         15  
  15         483  
37 15     15   43 use constant characteristic_integer => 1;
  15         14  
  15         552  
38 15     15   52 use constant values_min => 0;
  15         15  
  15         1153  
39             sub values_max {
40 0     0 1 0 my ($self) = @_;
41 0         0 return $self->{'radix'} - 1;
42             }
43              
44 15         45 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   49 };
  15         11  
53 15     15   46 use constant parameter_info_array => [ parameter_common_radix() ];
  15         15  
  15         1152  
54              
55             sub pred {
56 104     104 1 260 my ($self, $value) = @_;
57             return ($value == int($value)
58             && $value >= 0
59 104   33     382 && $value < $self->{'radix'});
60             }
61              
62             1;
63             __END__