To easily explain how to find the 2's complement of a binary number, follow these two steps:
Invert the bits: Change all 0s to 1s and all 1s to 0s in the given binary number. This is also known as finding the 1's complement.
Add 1: Add 1 to the result obtained from step 1, and if there's a carry bit after the last position, ignore it.
Let's illustrate with an example:
Given binary number: 1101 (which is 13 in decimal)
Step 1: Invert the bits
Original: 1101
Inverted: 0010
Step 2: Add 1
Inverted: 0010
+ 1
Result: 0011
So, the 2's complement of 1101 is 0011 (which is -3 in decimal, considering 1101 as a 4-bit signed binary number).
Matplotlib을 사용하여 관계대명사와 수동태의 영작과정 시각화하기 (0) | 2023.07.24 |
---|---|
Python 부트캠프 노트필기 (Day 1) (0) | 2023.04.11 |
댓글 영역