If a variable can take only integral values from 0 to n, where n is an…

2018

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)

  1. A.

    [log(n)] + 1 bits

  2. B.

    [log (n-1)) + 1 bits

  3. C.

    [log (n+1)] + 1 bits

  4. D.

    None of the above

Attempted by 310 students.

Show answer & explanation

Correct answer: A

To represent integral values from 0 to n, the bit-field must accommodate n + 1 distinct states. The minimum width required is floor(log2(n)) + 1 bits.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Isro