본문 바로가기
Major/Security

[논리설계] 04. Number System Comparison(Addition, Overflow, Increasing Bit Width)

by LeeDaSom 2025. 3. 27.

1. Addition

1) Decimal

2) Binary

 

📒 Add the following 4-bit binary numbers

📒 Add the following 4-bit binary numbers

2. Overflow

1) 디지털 시스템은 고정된 비트 수로 연산한다. 

2) Overflow: 결과값이 사용 가능한 비트 수보다 너무 커서 비트 안에 담을 수 없을 때 발생한다. 

📒 Exercise

3. Signed Binary Numbers

1) sign/magnitude numbers

 > 1 sign bit, N-1 magnitude bits

 > sign bit is the most significant (left-most) bit

   -Positive number: sign bit = 0

   -Negative number: sign bit =1

> example, 4-bit sign/mag representations of ± 6:

+6 = 0110

-6 = 1110

> Range of an N-bit sing/manitude number:

> Problems:

2) Two's complement numbers

4. Taking the Two's Complement

 1) Flip the sign of a two's complement number

 2) Method:

  (1) Invert the bits

  (2) Add 1

3) Example: Flip the sign of 3(decimal) = 0011(binary)

1100+1=1101

5. Two's Complement Addition

📒Exercise

 

6. Increasing Bit Width

Extend number from N to M bits (M > N):

1) Sign-extension

 Sign bit copied to msb's

 Number value is same

ex 1)

-4-bit representation  of 3 = 0011

-8-bit sign-extended value: 00000011

ex 2)

-4-bit representation of -5 = 1011

-8-bit sign-extended value: 11111011

 

2) Zero-extension

Zero copied to msb's

Value changes for negative numbers

ex 1)

-4-bit value = 0011=3

-8-bit zero-extended value: 00000011=3

ex 2)

-4-bit value = 1011=-5

-8-bit zero-extended value: 00001011 = 11

 

7. Number System Comparison