Math::NumSeq::RadixConversion -- radix conversion
use Math::NumSeq::RadixConversion; my $seq = Math::NumSeq::RadixConversion->new (radix => 2, to_radix => 10); my ($i, $value) = $seq->next;
This is integers converted from one radix to another. The default is binary converted to decimal,
0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, ...
For example i=3 in binary is 0b11 which is interpreted as decimal for value 11, ie. eleven.
The radix parameter is the from radix, and to_radix what it's converted to.
radix
to_radix
When radix < to_radix the effect is to give all integers which in to_radix use only the digits of radix. So the default is all integers which in decimal use only the binary digits, ie. 0 and 1.
radix < to_radix
When radix > to_radix the conversion is a reduction. The calculation is still a breakdown and re-assembly
radix > to_radix
dk*radix^k + d2*radix^2 + ... + d1*radix + d0 = i value = dk*to_radix^k + d2*to_radix^2 + ... + d1*to_radix + d0
but with to_radix being smaller it's a reduction. For example radix=10 i=123 with to_radix=8 gives 1*8^2+2*8+3=83.
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::RadixConversion->new ()
$seq = Math::NumSeq::RadixConversion->new (radix => $r, to_radix => $t)
Create and return a new sequence object.
$value = $seq->ith($i)
Return $i as digits of base radix encoded in to_radix.
$i
$bool = $seq->pred($value)
Return true if $value occurs in the sequence ...
$value
Math::NumSeq, Math::NumSeq::DigitSum, Math::NumSeq::HarshadNumbers
http://user42.tuxfamily.org/math-numseq/index.html
Copyright 2012 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
To install Math::NumSeq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::NumSeq
CPAN shell
perl -MCPAN -e shell install Math::NumSeq
For more information on module installation, please visit the detailed CPAN module installation guide.