On 2020-02-04 17:08, Paul Procacci wrote:
The only thing that's wrong is that you didn't account for leading zero's.
Your initial question has a type who's size is always 1 byte.
However your second question, the one where 'something is wrong' requires more bits of information to hold the given value. You need to modify the sprintf to pad the binary number with the leading zeros  (Or you can look at Tom's module which I haven't done).

my $alignment = 8;
my $u = 0x4D4F;
my $padding = $alignment + $u.msb - ( $u.msb +& ( $alignment  - 1 ) );
say '$u = <0b' ~ "\%0{$padding}b".sprintf($u).comb(/\d ** 4/).join('_') ~ '>;';

That explains it. Thank you!

Reply via email to