Calculating bits required to store decimal number

后端 未结 12 802
自闭症患者
自闭症患者 2020-12-23 22:21

This is a homework question that I am stuck with.

Consider unsigned integer representation. How many bits will be required to store a decimal number

12条回答
  •  孤独总比滥情好
    2020-12-23 23:03

    Assuming that the question is asking what's the minimum bits required for you to store

    1. 3 digits number

    My approach to this question would be:

    • what's the maximum number of 3 digits number we need to store? Ans: 999
    • what's the minimum amount of bits required for me to store this number?

    This problem can be solved this way by dividing 999 by 2 recursively. However, it's simpler to use the power of maths to help us. Essentially, we're solving n for the equation below:

    2^n = 999
    nlog2 = log999
    n ~ 10
    

    You'll need 10 bits to store 3 digit number.

    Use similar approach to solve the other subquestions!

    Hope this helps!

提交回复
热议问题