Need Help about range of numbers?

Discussion in 'Programmer's Corner' started by JahanzaibNiazi, Jan 5, 2013.

  1. JahanzaibNiazi

    Thread Starter New Member

    Jan 5, 2013
    1
    0
    Give range of following numbers that could be stored in 9-bit space?
    (a). Unsigned Numbers.
    (b).Positive numbers.
    (c).Negative Numbers.

    Kindly give me the reply i will be thankful to you.......
     
  2. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    2 to the power of 9 = 512 possible iterations...

    I'm sure you can do the rest...
     
    Last edited: Jan 5, 2013
  3. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,790
    827
    Think first about part a. Lets try a thought experiment. How many numbers can you represent with 1 bit? How about 2 bits? Or 3 bits? From here, you can probably figure out how many unsigned numbers can be represented with 9 bits, or even generalize YOUR solution to 'n' bits. Once this exercise is completed, and knowing how signed numbers are represented in binary, you can try parts b and c.
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    Try to work through the answers for (a), (b) and (c) on your own. What are the answers for 2 bits, 3 bits and 4 bits?

    From there it will be easy to work out the answers for any number of bits, as djsfantasi says.

    The general rule on this forum is not to give you the answer immediately but to encourage you to do the thinking for yourself.

    Show us your answers and how you arrived at your answers. Then we will provide assistance.
     
  5. WBahn

    Moderator

    Mar 31, 2012
    17,715
    4,788
    This seems like a question that probably should be in the Homework Help forum.

    The answer to part (a) is very straight forward, but the answers to parts (b) and (c) are a bit ambiguous because it depends on how you have chosen to represent positive and negative values and also whether you choose to include 0 in the count of either positive or negative values.
     
Loading...