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

**URL:** <https://discourse.julialang.org/t/any-way-to-auto-reformat-binary-without-extra-tail-000s/49944>\
**Category:** Numerics\
**Created:** [November 10, 2020, 8:41pm UTC](https://discourse.julialang.org/t/any-way-to-auto-reformat-binary-without-extra-tail-000s/49944 "2020-11-10T20:41:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 10, 2020, 8:41pm UTC](https://discourse.julialang.org/t/any-way-to-auto-reformat-binary-without-extra-tail-000s/49944/1 "2020-11-10T20:41:32Z")

</div>

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

```julia
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

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 10, 2020, 8:44pm UTC](https://discourse.julialang.org/t/any-way-to-auto-reformat-binary-without-extra-tail-000s/49944/2 "2020-11-10T20:44:02Z")

</div>

Ooops ! I ve just removed the bswap (???) and it returns what I wanted now !  
🙃 😄  
👍
