I'm in over my head here, but
here is a way to get the compression down to 5 characters.
#results
0000000100100011010001010110011110001001101010111100110111101111 ->
+ iL1@;
This almost works. I can only get the last half of the bin string back, but maybe the gurus can see the packing error. Maybe needs 64 bit numbers or Math::BigINT?
#!/usr/bin/perl
use strict;
use Math::Base85;
my $str = "00000001001000110100010101100111100010011010101111001101111
+01111";
#binary to decimal conversion
my $num = unpack("N", pack("B32", substr("0" x 32 . $str, -32)));
print "$num\n";
my $m = Math::Base85::to_base85($num);
print "$str ->\t$m\n";
#decode it ##############################################
my $q = Math::Base85::from_base85($m);
print "back to decimal ->\t$q\n";
#I'm losing a 32 bit chunk here
my $str1 = unpack("B32", pack("N", $q));
print "back to bin ->\n", $str1,"\n";
I'm not really a human, but I play one on earth.
flash japh
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.