Question:

How many bits are require to represent an arbitrary number X?

by  |  earlier

0 LIKES UnLike

(assume unsigned number). I get that to represent 5 states, you need 3 bits (b/c you can represent 8 total with 3 bits). But when you represent a certain number like 5,435, how do you find out the number of bits needed? How many bits are then required to represent an arbitrary number X?

 Tags:

   Report

3 ANSWERS


  1. Well..... bits really are just the computer's way of storing the binary data.  So whatever number you have, convert it to binary, and the number of 1/0s are how many bits would be needed.  In your example, 5 in binary is 101, thus the 3 bits.  And a byte is 8 bits because every character in ASCII can be represented using just an 8 digit binary number.


  2. 5435 is base 10.  Write it in binary, count the digits!

    Not very practical for "arbitrary number", unless you write a program to do so...

    That program will just convert base 10 in base 2.

    You could, also, make a table of "limits"

    1 bit, 0 and 1, max = 1 (2-1)

    2 bits, max = 3 (4-1)

    3 bits, max = 7 (8-1)

    4 bits, max = 15 (16-1)

    5 bits, max = ...

    8 bits: 255

    16 bits: 65535 etc...

    check in which range the "arbitrary number" fits...


  3. Number of bits N = log (base 2) X, rounded up to the nearest integer.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.