Binary Arithmetic

Download Report

Transcript Binary Arithmetic

BINARY ARITHMETIC

350151 – Digital Circuit 1 Choopan Rattanapoka

Binary Arithmetic  Addition ( + )  Subtraction ( - )  Multiplication ( x )  Division ( / )

Binary Addition (1)  Recall decimal addition

Binary Addition (2)  Binary addition

Example  Add the following binary numbers :  10010011 + 01001011 1 1 1 0 0 1 0 0 1 1 0 1 0 0 1 0 1 1 +

1 1 0 1 1 1 1 0

Exercise 1  Add the following binary numbers (answer in binary and decimal number) :  1010 + 1001  11011 + 00111  101101 + 100100  11010101 + 01101011  10001111 + 11000001

Binary Subtraction (1)  Recall decimal subtraction  100 – 28

-

1 0 9 10 10 0 0 2 7 8 2

Binary Subtraction (2) 0 - 0 = 0 

0 - 1 = 1

 1 - 0 = 1 1 - 1 = 0   0 borrow 0

1 borrow 1

1 borrow 0 0 borrow 0 10 – 01  0 2 1 0 0 1 0 1 -

Example  11011 – 10101 1 1 0 0 1 0 0 2 0 1 1 1 0 1 1 1 0

Exercise 2  Subtract the following binary numbers (answer in binary and decimal number) :  1010 - 1001  11011 - 00111  101101 - 100100  11010101 - 01101011  10000000 - 01000001

Binary Multiplication (1)  Recall decimal multiplication  125 x 12 x 1 1 1 2 2 5 2 1 5 5 0 5 2 0 + 0

Binary Multiplication (2)  A basic rules for binary multiplication  0 x 0  0  0 x 1  0  1 x 0  0  1 x 1  1

Example  1000011 x 1101 1 0 0 0 0 1 1 x 1 1 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 + 1 0 0 0 0 1 1 + + 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 1 1

Exercise 3  Multiply the following binary numbers:  110 x 10  0110 x 1010  101 x 101

Binary Division  Recall decimal devision  125 / 5 5 1 1 2 2 0 2 2 5 5 5 5 0 -

Example  100011 / 101 0 0 0 1 1 1 101 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 0 1 1 0 1 0

Exercise 4  Divide in binary:  10001101 / 110  110000011 / 1011  1110100 / 1010

Exercise 5 (TODO)   Add, Subtract, and multiply in binary:       1111 and 1001 1111 and 1010 110010 and 11101 110110 and 11101 100100 and 10110 1101001 and 110110 Divide in binary:    11101001 / 101 110000001 / 1110 1110010 / 1001