Any way to auto-reformat Binary without extra tail "000s..."

Hi, using the Dec to Bin convertion, I’ve pickup this lines of codes which seem to do the job :

dek = 21
string(bswap(dek), base = 2)
"1010100000........."

Now, in this way I’m getting a very long format :
Out[9]:

“1010100000000000000000000000000000000000000000000000000000000”
…A bit too loing for me;
So, is there a way to *auto reformat the Binary output so that it will returns only the needed number digit lenght: ie; “10101” …without a zilion 0 behind ?
61 bit length ???
*auto meaning here, it should also adapt to the input number I’m using from 1 to 1000000 for example.
Thanks

Ooops ! I ve just removed the bswap (???) and it returns what I wanted now !
:upside_down_face: :smile:
:+1:

1 Like