Binary Numbers Decimal Base 10 Numbers Each digit
Binary Numbers
Decimal (Base 10) Numbers ® Each digit in a decimal number is chosen from ten symbols: { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ® Position (right to left) of each digit represents a power of ten. ® Example: Consider the decimal number 2307 position: 2 3 0 7 3 2 1 0 2307 = 2 103 + 3 102 + 0 101 + 7 100
Binary (Base 2) Numbers ® Each digit in a binary number is chosen from two symbols: { 0, 1 } ® Position (right to left) of each digit represents a power of two. ® Example: Convert binary number 1101 to decimal position: 1101 1 20 = 1 1 0 1 3 2 1 0 1 23 + 1 22 + 0 21 +
Adding Binary Numbers 101 + 10 ---- 111
Adding Binary Numbers 11 carry 111 + 110 ----1101 ® 111 + 110 = ( 1 22 + 1 21 + 1 20 ) +
Converting Decimal to Binary Decimal 0 1 2 3 4 5 6 7 8 conversion 0 = 0 20 1 = 1 20 2 = 1 21 + 0 20 3 = 2+1 = 1 21 + 1 20 4 = 1 22 + 0 21 + 0 20 5 = 4+1 = 1 22 + 0 21 + 1 20 6 = 4+2 = 1 22 + 1 21 + 0 20 7 = 4+2+1 = 1 22 + 1 21 + 1 20 8 = 1 22 + 0 21 + 0 20 Binary 0 1 10 11 100 101 110 111 1000
Converting Decimal to Binary ® Repeated division by two until the quotient is zero ® Example: Convert decimal number 54 to binary remainder 1 1 0 Binary representation of 54 is 110110
Converting Decimal to Binary 1 1 0 l l Subtracting highest power of two 1 s in positions 5, 4, 2, 1 1 32 = 0 6 8 1 32 + 1 16 = + 1 32 3 16 = 3 16 + 0 8 13 4 = 6 8 + 1 4 27 2 = 13 4 + 1 2 = 27 2 + 0 1 54 54 - 25 = 22 22 - 24 = 6 6 - 22 =2 2 - 21 = 0 110110
Problems ® Convert 1011000 to decimal representation ® Add the binary numbers 1011001 and 10101 and express their sum in binary representation ® Convert 77 to binary representation
Solutions ® Convert 1011000 to decimal representation 1011000 = 1 26 + 0 25 + 1 24 + 1 23 + 0 22 + 0 21 + 0 20 = 1 64 + 0 32 + 1 16 + 1 8 + 0 4 + 0 2 + 0 1 = 64 + 16 + 8 = 88 ® Add the binary numbers 1011001 and 10101 and express their sum in binary representation 1011001 + 10101 ------1101110
Solutions ® Convert 77 to binary representation 1 0 0 1 1 0 1 Binary representation of 77 is 1001101
In-Class Exercises Ternary (Base 3) representation – Numbers are represented with the digits 0, 1, 2 ® Problems: – Convert the ternary numbers 1021 and 2001 to decimal representation – Add the ternary numbers 1021 and 2001 and express their sum in ternary representation – Convert 77 to ternary representation ® In general, the base N representation of a number may only consist of what digits? ? ? ®
- Slides: 12