-
-
13 Aug 2017 00:35:52 UTC
- Distribution: Encode-Positive-Digits
- Module version: 20170811
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (389 / 0 / 182)
- Kwalitee
Bus factor: 1- 84.18% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (3.61KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Math::BigInt
- Test::More
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
Name
Encode::Positive::Digits - Encode a positive integer using the specified digits and vice-versa
Synopsis
use Encode::Positive::Digits; ok 101 == Encode::Positive::Digits::encode( "5", "01"); ok 5 == Encode::Positive::Digits::decode("101", "01"); ok "hello world" eq Encode::Positive::Digits::encode(4830138323689, " abcdefghlopqrw"); ok 4830138323689 == Encode::Positive::Digits::decode("hello world", " abcdefghlopqrw");
The numbers to be encoded or decoded can be much greater than 2**64 via support from Math::BigInt, such numbers should be placed inside strings to avoid inadvertent truncation.
my $n = '1'.('0'x999).'1'; my $d = Encode::Positive::Digits::decode($n, "01"); my $e = Encode::Positive::Digits::encode($d, "01"); ok $n == $e ok length($d) == 302; ok length($e) == 1001; ok length($n) == 1001;
Description
Encode and decode
encode
Returns a string which expresses a positive integer in decimal notation as a string using the specified digits. The specified digits can be any characters chosen from the Unicode character set.
1 $number Decimal integer 2 $digits Encoding digits
decode
Return the integer expressed in decimal notation corresponding to the value of the specified string considered as a number over the specified digits
1 $number Number to decode 2 $digits Encoding digits
Index
Installation
This module is written in 100% Pure Perl and, thus, it is easy to read, use, modify and install.
Standard Module::Build process for building and installing modules:
perl Build.PL ./Build ./Build test ./Build install
Author
Copyright
Copyright (c) 2016-2017 Philip R Brenan.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
Module Install Instructions
To install Encode::Positive::Digits, copy and paste the appropriate command in to your terminal.
cpanm Encode::Positive::Digits
perl -MCPAN -e shell install Encode::Positive::Digits
For more information on module installation, please visit the detailed CPAN module installation guide.