10進数155を2進数で表したものはどれか。
令和2年度 ITパスポート試験 問62
This question's explanation and your answers so far.
問 62
- ア
正解 Convert the decimal number 155 to binary. Taking out the powers of 2 contained in 155 from the largest downward gives 155 = 128 + 16 + 8 + 2 + 1. Setting the corresponding bit positions 2^7, 2^4, 2^3, 2^1, 2^0 to 1 and the rest to 0 gives 2^7=1, 2^6=0, 2^5=0, 2^4=1, 2^3=1, 2^2=0, 2^1=1, 2^0=1, i.e. “10011011”. Therefore the correct answer is ア. The repeated-division method gives the same result: 155÷2=77 remainder 1, 77÷2=38 remainder 1, 38÷2=19 remainder 0, 19÷2=9 remainder 1, 9÷2=4 remainder 1, 4÷2=2 remainder 0, 2÷2=1 remainder 0, 1÷2=0 remainder 1; arranging the remainders from the lowest bit upward again yields 10011011.
Incorrectイ
Converting 10110011 back to decimal gives 128 + 32 + 16 + 2 + 1 = 179, not 155.
Incorrectウ
Converting 11001101 back to decimal gives 128 + 64 + 8 + 4 + 1 = 205, not 155.
Incorrectエ
Converting 11011001 back to decimal gives 128 + 64 + 16 + 8 + 1 = 217, not 155.
- Radix conversion from decimal to binary. It can be done either by repeated division (repeatedly dividing by 2 and arranging the remainders from the lowest bit upward), or by decomposing the number into a sum of powers of 2 and setting the corresponding bits.
- Verify by converting back. The weights of the 8 bits from the highest to the lowest are 128, 64, 32, 16, 8, 4, 2, 1; summing the weights of the bits set to 1 confirms that the original decimal number is restored.