Skip to content

平成24年度 春期 ITパスポート試験 問52

This question's explanation and your answers so far.

問52
頻出度★★☆

負の整数を2の補数で表現するとき,8桁の2進数で表現できる数値の範囲を10進数で表したものはどれか。

出典 平成24年度 春期 ITパスポート試験 問52
解説

問 52

  • Incorrectア

    −256 to 255 would represent 512 values in total, twice the 256 patterns that 8 bits can distinguish. This is the mistake of applying the count 2^8 = 256 directly to the endpoints of the range; 8 bits cannot represent that many values.

  • Incorrectイ

    −255 to 256 also amounts to 512 values in total, exceeding the representational capacity of 8 bits (256 patterns). Moreover, in two's complement the largest positive value is 2^(n−1)−1 = 127, so a value such as 256 can never be the upper limit on the positive side.

  • ウ

    正解 An 8-digit (8-bit) binary number can form 2^8 = 256 different bit patterns. In two's complement representation the most significant bit is treated as the sign: patterns whose top bit is 0 (00000000 to 01111111) represent 0 to 127, and patterns whose top bit is 1 (10000000 to 11111111) represent −128 to −1. The range of values that can be represented is therefore −128 to 127, so option ウ is correct. In general, n-bit two's complement covers −2^(n−1) to 2^(n−1)−1, and substituting n=8 gives −2^7 = −128 through 2^7−1 = 127. Because zero has only one representation, the negative side holds one more value than the positive side, which makes the range characteristically asymmetric.

  • Incorrectエ

    −127 to 128 does contain the correct count of 256 values, but the asymmetry points the wrong way. In two's complement 10000000 represents −128, so it is the negative side that has one extra value; conversely, +128 cannot be represented in 8-bit two's complement (representing +128 would require 9 bits).

ここがポイント
  • The range representable in n-bit two's complement is −2^(n−1) to 2^(n−1)−1. For 8 bits it is −128 to 127, and for 16 bits it is −32768 to 32767.
  • In two's complement, zero has only one representation, so one more negative number can be represented than positive numbers, making the range asymmetric (the most significant bit indicates the sign).
用語

Your answers