jeudi 1 janvier 2015

bc output binary as nibbles separated by whitespace


I'm debugging code which contains quite a few bit shift operations, and I'm using bc a lot to look at what's happening on the bit level.


Here's what I use:



$ echo 'obase=2;598980975283696640' | bc
100001010000000000100000011000000011000000000111010000000000


Is there a simple way to get the output as whitespace-separated nibbles? E.g.



1000 0101 0000 0000 0010 0000 0110 0000 0011 0000 0000 0111 0100 0000 0000


Thanks in advance for your answers!



Aucun commentaire:

Enregistrer un commentaire