Math::BaseArith - Perl extension for mixed-base number representation (like APL encode/decode)
use Math::BaseArith qw( :all ); encode_base( value, base_listref ); decode_base( representation_listref, base_listref );
The inspiration for this module is a pair of functions in the APL programming language called encode (a.k.a. "represent" or "antibase)" and decode (a.k.a. base). Their principal use is to convert numbers from one number base to another. Mixed number bases are permitted.
In this perl implementation, the representation of a number in a particular number base consists of a list refence (listref) whose elements are the digit values in that base. For example, the decimal number 31 would be expressed in binary as a list of five ones with any number of leading zeros: [0, 0, 0, 1, 1, 1, 1, 1]. The same number expressed as three hexadecimal (base 16) digits would be [0, 1, 15], while in base 10 it would be [0, 3, 1]. Fifty-one inches would be expressed in yards, feet, inches as [1, 1, 3], an example of a mixed number base.
Gary Puckering <jgpuckering@rogers.com> (CPAN author PUCKERING)
To install Math::BaseArith, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::BaseArith
CPAN shell
perl -MCPAN -e shell install Math::BaseArith
For more information on module installation, please visit the detailed CPAN module installation guide.