For a positive integer N, the number of bits required is tied to the highest power of 2 not exceeding N. If 2^(k−1) ≤ N ≤ 2^k − 1, the number uses k bits. Taking base-2 logarithms gives k − 1 ≤ log₂N < k, so k = ⌊log₂N⌋ + 1. This matches the theoretical formula for bit-length.
Option A:
Option A expresses this relationship exactly, using the floor function to convert the real logarithm to an integer count of bits. It ensures that every value in the closed interval of integers with the same magnitude uses the same bit-length.
Option B:
Option B, ⌈log₂N⌉, overestimates the bit-length when N is a power of 2 because log₂N is then an integer and the ceiling does not add 1. It thus fails to capture the inclusive nature of the range.
Option C:
Option C, log₂(N−1), omits rounding and the +1 term, and can be undefined for N = 1. It does not yield a discrete measure of bit-length.
Option D:
Option D, 2×log₂N, doubles the logarithmic value and has no standard interpretation as a digit count. It grossly misestimates the number of bits required.
Comment Your Answer
Please login to comment your answer.
Sign In
Sign Up
Answers commented by others
No answers commented yet. Be the first to comment!