Neat solution...but when using 'B', it produces numbers greater than 6-bits can hold:
P:\test>perl
print join'|',
unpack "C*", # 16 6-bit numeric values
pack "B6"x16, # string of 16 bytes, each holding a 6-bit value
unpack "a6"x16, # 16 6-character base-2 strings
unpack "B*", # 96-character base-2 string
"twelve bytes"; # 12-byte packed string
^Z
116|28|116|148|108|28|100|148|32|24|36|228|116|24|84|204
Switching to 'b' fixes that:
P:\test>perl
print join'|',
unpack "C*", # 16 6-bit numeric values
pack "b6"x16, # string of 16 bytes, each holding a 6-bit value
unpack "a6"x16, # 16 6-character base-2 strings
unpack "b*", # 96-character base-2 string
"twelve bytes"; # 12-byte packed string
^Z
52|29|23|25|44|25|23|25|32|8|22|30|52|21|54|28
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
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.
|
|