Open In App

ISRO | ISRO CS 2018 | Question 62

If a variable can take only integral values from 0 to n, where n is an integer, then the variable can be represented as a bit-field whose width is (the log in the answers are to the base 2, and [log n] means the floor of log n)
(A) [log(n)] + 1 bits
(B) [log (n-1)) + 1 bits
(C) [log (n+1)] + 1 bits
(D) None of the above

Answer: (A)
Explanation: Suppose a number 64 is to represented as a bit-field then its width would be [log(n)] + 1 (with base 2).
So, ((log264) + 1) = 6 + 1 = 7 bits are required.

Option (A) is correct.
Quiz of this Question

Article Tags :