Search code examples
twos-complement7-bit

Seven bit and two compliment


If we use seven-bit two's complement binary representation for integers, what is The number of integers (things) that can be represented in this way? The smallest (most) negative integer that can be represented in this way? The largest positive integer that can be represented in this way?

  • This is a CS homework question that I am having trouble answering and explaining. Any help would be appreciated.

Solution

  • So its really easy

    Counting in binary usually goes like

    >00000000 (8) = 0
    >00000001 (8) = 1
    >00000010 (8) = 2
    >00000011 (8) = 3
    >etc...etc.
    

    In 7 bit the last bit is what decides if its a negative or positive

    1 being negative and 0 being positive

    > 10000000 = -128
    > 10000001 = -127
    > 10000010 = -126
    > On...and on...
    > 11111111 = -1
    > 00000000 = 0
    > 00000001 = 1
    > 01111111 = 127
    

    So lowest you can go is -128

    Highest you can go is 127