in reply to Converting negative number to binary with specific width
I prefer bit-bashing to string-bashing. Whatever floats your boat.
printf '%0*b', $bits, $num & ((1<<$bits)-1)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting negative number to binary with specific width
by Anonymous Monk on Nov 03, 2015 at 15:28 UTC |