Skip to main content

Count total bits in a number

The total number of bits in a number refers to the total number of binary digits used to represent the number in binary form.

For example, the decimal number 10 can be represented in binary form as 1010. In this case, the total number of bits used to represent the number is 4.

The total number of bits used to represent a number depends on the number of bits used in the binary number system. For example, in a 8-bit system, numbers can be represented using 8 binary digits, while in a 32-bit system, numbers can be represented using 32 binary digits.

In general, the total number of bits required to represent a number depends on the range of values that the number can take and the precision required to represent it.

Given a positive number, Our goal is to find number of bits which is present in given number.

 Number : 34  
 Output : 6
    [34 : 100010]
        |<------>|  = 6
 Number : 256
 Output : 9
   [255 : 100000000]
        |<--------->|  = 9 

Here given code implementation process.





Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment