1Math::NumSeq::RadixConvUesresrioCno(n3t)ributed Perl DocMuamtehn:t:aNtuimoSneq::RadixConversion(3)
2
3
4

NAME

6       Math::NumSeq::RadixConversion -- radix conversion
7

SYNOPSIS

9        use Math::NumSeq::RadixConversion;
10        my $seq = Math::NumSeq::RadixConversion->new (from_radix => 2,
11                                                      to_radix => 10);
12        my ($i, $value) = $seq->next;
13

DESCRIPTION

15       This sequence is the index i converted from one radix to another.  The
16       default is from binary to decimal,
17
18           0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, ...
19           starting i=0
20
21       For example i=3 in binary is 0b11 which is interpreted as decimal for
22       value 11, ie. eleven.
23
24       When "from_radix < to_radix" the effect is to give values which in
25       "to_radix" use only the digits of "from_radix".  The default is all
26       integers which in decimal use only the binary digits, ie. 0 and 1.
27
28       When "from_radix > to_radix" the conversion is a reduction.  The
29       calculation is still a breakdown and re-assembly
30
31           i = d[k]*from_radix^k + ... + d[1]*from_radix + d[0]
32           value = d[k]*to_radix^k + ... + d[1]*to_radix + d[0]
33
34       but because "to_radix" is smaller the value is smaller than the index
35       i.  For example from_radix=10 and to_radix=8 turns i=345 into
36       value=3*8^2+4*8+5=229.
37

FUNCTIONS

39       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
40       classes.
41
42       "$seq = Math::NumSeq::RadixConversion->new ()"
43       "$seq = Math::NumSeq::RadixConversion->new (from_radix => $r, to_radix
44       => $t)"
45           Create and return a new sequence object.
46
47   Random Access
48       "$value = $seq->ith($i)"
49           Return $i as digits of base "radix" encoded in "to_radix".
50
51       "$bool = $seq->pred($value)"
52           Return true if $value occurs in the sequence.
53
54           If "to_radix <= from_radix" then all integer $value occurs.  If
55           "to_radix > from_radix" then $value written in "to_radix" must use
56           only digits 0 to "from_radix - 1" inclusive.
57

SEE ALSO

59       Math::NumSeq, Math::NumSeq::DigitSum, Math::NumSeq::HarshadNumbers
60

HOME PAGE

62       <http://user42.tuxfamily.org/math-numseq/index.html>
63

LICENSE

65       Copyright 2012, 2013, 2014 Kevin Ryde
66
67       Math-NumSeq is free software; you can redistribute it and/or modify it
68       under the terms of the GNU General Public License as published by the
69       Free Software Foundation; either version 3, or (at your option) any
70       later version.
71
72       Math-NumSeq is distributed in the hope that it will be useful, but
73       WITHOUT ANY WARRANTY; without even the implied warranty of
74       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
75       General Public License for more details.
76
77       You should have received a copy of the GNU General Public License along
78       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
79
80
81
82perl v5.28.1                      2014-06-29  Math::NumSeq::RadixConversion(3)
Impressum