Binary to Decimal Conversion SumofWeights 100112 1 x
Binary to Decimal Conversion • Sum-of-Weights • 100112 • (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21) + (1 x 20) • Terms 16, 0, 0, 2 and 1 • 19
Binary to Decimal Conversion • • Add weights of non-zero terms Weights increase/decrease by power of 2 100112 = 16 + 2 + 1 = 19 1011. 1012 = 8 + 2 + 1/2 + 1/8 = 11 + 5/8 = 11. 625
Decimal to Binary Conversion number 392 196 98 Quotient after division 196 98 49 Remainder after division 0 (b 0) 0 (b 1) 0 (b 2) 49 24 24 12 1 0 (b 3) (b 4) 12 6 3 1 0 0 0 1 1 (b 5) (b 6) (b 7) (b 8)
Binary-Decimal fraction conversion • Binary to Decimal Conversion – Sum-of-Weights method – Weights decrease by a factor of 2 – 0. 11012 weights ½, ¼, 1/16 – Sum up to 0. 8125 • Decimal to Binary Conversion – Repeated Multiplication by 2 – example
Decimal-Binary fraction conversion • Decimal to Binary Conversion – Repeated multiplication by 2 Number Mult. By 2 Integer 0. 8125 1. 625 1 (b-1) 0. 625 1. 250 1 (b-2) 0. 250 0. 500 0 (b-3) 0. 500 1. 000 1 (b-4)
Binary Arithmetic • • Binary Addition Binary Subtraction Binary Multiplication Binary Division
Binary Addition • Four Basic rules for binary addition 1 st digit 0 0 1 1 n 2 nd digit Sum 0 0 1 1 0 Carry 0 0 0 1 Addition of multiple binary numbers
Binary Addition
Binary Subtraction • Four Basic rules for binary subtraction 1 st digit 0 0 1 1 2 nd digit Difference 0 0 1 1 0 Borrow 0 1 0 0
Binary Subtraction Borrow 1 st Number 1 1 0 1 1 2 nd Number 1 1 0 Result 1 0 1
Binary Multiplication • Four Basic rules for binary multiplication n 1 st digit 0 0 1 2 nd digit Product 0 0 1 0 0 0 1 1 1 Example of Binary Multiplication
Binary Multiplication 1 st product term 2 nd product term 3 rd product term Product 1101 x 101 1101 0000 1101 1000001 (13) (5) (65)
Multiplication and division by shifting bits • Shift left 1 digit is multiply by 10 or 2 • Shift right 1 digit is divide by 10 or 2 • Binary 111012 (29) shifted left by one bit • 1110102 (58) • Shift left 1 bit is multiply by 2
Binary Division 10 101 | 1101 011 000 11
Signed and Unsigned Numbers • Unsigned Binary Numbers • Signed Binary Numbers – Most significant bit represents sign – 0 represents a positive number – 1 represents a negative number
2’s Complement form • 1’s complement form • 2’s complement form Binary number 1’s complement 2’s complement 01101(13) 10010 + 1 10011(-13)
Addition and Subtraction with 2’s Complement 0101 0010 0111 +5 +2 +7 0101 1110 0011 +5 -2 +3 1011 1110 1001 -5 -2 -7 1011 0010 1101 -5 +2 -3
- Slides: 17