Complements of Binary Numbers

Only for negative
its goal is to convert a number to positive to be able to work with it

First complement: flipping the bits: 0’s to 1’s and 1’s to 0’s

Ex: 11001011 -> 00110100

Second complement: adding one to the LSB

Ex: 11001011 -> 00110100 -> 00110101

Sign-magnitude:

MSB is reserved for the sign of the numbers. Deals with both negative and positive numbers.
7 bits for the number itself, and 1 for the sign of the number (adds up to 8-bit)

Getting different results for the different methods is normal; every system uses a different way to represent the same numbers


Assignment:

1101 + 1010
10111 + 01101
2.
1101 - 0100
1001 - 0111
3.
110 * 111
1100 / 011


## Signed Numbers Arithmetic Operations
Overflow Condition

Occurs when:

  • Both numbers added are positive
  • Both numbers added are negative
    is indicated when the sign bit of the result is different than the sign bit of the added numbers
Subtraction

There’s no subtraction in signed. We add in a special way instead.

Number System

TypeBaseDigits
Binary20 :LiArrowRight: 1
Decimal100 :LiArrowRight: 9
Hexadecimal160 :LiArrowRight: F
Hexadecimals Counting:

0 through 9 then A through F

Ex:

E = 14, 1F = 20

Binary-to-Hexadecimal Conversion