Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

In how many bits do I fit

JavaScript (ES6), 18 bytes

Click to copy
f=n=>n&&1+f(n>>>1)
Click to copy
<input type=number min=0 step=1 value=8 oninput="O.value=f(this.value)">
<input id=O value=4 disabled>


05AB1E, 2 bytes

Click to copy
bg

Try it online!


x86 Assembly, 4 bytes

Assuming Constant in EBX:

Click to copy
bsr eax,ebx
inc eax

EAX contains the number of bits necessary for Constant.

Bytes: ☼¢├@

Hexadecimal: ['0xf', '0xbd', '0xc3', '0x40']

Tags:

Binary

Code Golf

Related

Coprimes up to N Absolute Sums of Sidi Polynomial Coefficients Big Ben goes BONG Is it a Mersenne Prime? Sprunge this! Sprunge that! Merry Golfmas, Everyone! Random Pixel Poking ASCII Hilbert Curve Are you lost yet? KeyPad Code to Text! Crazy 8s Code Golf Shortest auto-destructive loop

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy