Bit-Vector

 view release on metacpan or  search on metacpan

lib/Bit/Vector/String.pod  view on Meta::CPAN

Returns an octal string representing the given bit vector.

Note that this method is not particularly efficient, since it
is almost completely realized in Perl, and moreover internally
operates on a Perl list of individual octal digits which it
concatenates into the final string using "C<join('', ...)>".

A benchmark reveals that this method is about 40 times slower
than the method "C<to_Bin()>" (which is realized in C):

 Benchmark: timing 10000 iterations of to_Bin, to_Hex, to_Oct...
     to_Bin:  1 wallclock secs ( 1.09 usr +  0.00 sys =  1.09 CPU)
     to_Hex:  1 wallclock secs ( 0.53 usr +  0.00 sys =  0.53 CPU)
     to_Oct: 40 wallclock secs (40.16 usr +  0.05 sys = 40.21 CPU)

Note that since an octal digit is always worth three bits,
the length of the resulting string is always a multiple of
three bits, regardless of the true length (in bits) of the
given bit vector.

Also note that the B<LEAST> significant octal digit is

lib/Bit/Vector/String.pod  view on Meta::CPAN

Remember also that the least significant bits are always to the
right of an octal string, and the most significant bits to the left.
Therefore, the string is actually reversed internally before storing
it in the given bit vector using the method "C<Chunk_List_Store()>",
which expects the least significant chunks of data at the beginning
of a list.

A benchmark reveals that this method is about 40 times slower than
the method "C<from_Bin()>" (which is realized in C):

 Benchmark: timing 10000 iterations of from_Bin, from_Hex, from_Oct...
   from_Bin:  1 wallclock secs ( 1.13 usr +  0.00 sys =  1.13 CPU)
   from_Hex:  1 wallclock secs ( 0.80 usr +  0.00 sys =  0.80 CPU)
   from_Oct: 46 wallclock secs (44.95 usr +  0.00 sys = 44.95 CPU)

If the given string contains any character which is not an octal digit
(i.e., [0-7]), a fatal syntax error ensues ("unknown string type").

Note especially that this method does B<NOT> accept any uniquely
identifying format prefix (such as "0o") in the given string; the
presence of such a prefix will also lead to the fatal "unknown



( run in 0.747 second using v1.01-cache-2.11-cpan-71847e10f99 )