Discussion
If a variable can take only integral values from 0 to n. where n is a constant integer, then the variable can be represented as a bit-field whose width is the integral part of (the log in the answers arc to the base 2)
Answer: A
Correct answer: log (n) + 1
To represent every value from 0 to \( n \) requires enough bits to express \( n \) itself, which takes \( \lfloor \log_2 n \rfloor + 1 \) bits.
Checking with \( n = 7 \): \( \lfloor \log_2 7 \rfloor + 1 = 2 + 1 = 3 \) bits, which gives the eight values 0 to 7 - correct. With \( n = 8 \) it gives \( 3 + 1 = 4 \) bits, since three would only reach 7. The other expressions fail one or other of these checks.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development