If you insist on strings, substr is still probably easier than pack.
substr(sprintf("%0*b", $bits, $num), -$bits)In reply to Re^2: Converting negative number to binary with specific width
by Anonymous Monk
in thread Converting negative number to binary with specific width
by pjkang7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |