870 likes | 2.3k Views
1000. 100. 10. 1. 7. 4. 7. 5. Decimal Number System. Base (Radix) 10 Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 e.g. 7475 10. The magnitude represented by a digit is decided by the position of the digit within the number.
E N D
1000 100 10 1 7 4 7 5 Decimal Number System Base (Radix) 10 Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 e.g. 747510 The magnitude represented by a digit is decided by the position of the digit within the number. For example the digit 7 in the left-most position of 7475 counts for 7000 and the digit 7 in the second position from the right counts for 70.
8=23 4=22 2=21 1=20 1 1 1 0 Binary Number System Base (Radix) 2 Digits 0, 1 e.g. 11102 The digit 1 in the third position from the right represents the value 4 and the digit 1 in the fourth position from the right represents the value 8.
512=83 64=82 8=81 1=80 1 6 2 3 Octal Number System Base (Radix) 8 Digits 0, 1, 2, 3, 4, 5, 6, 7 e.g. 16238 The digit 2 in the second position from the right represents the value 16 and the digit 1 in the fourth position from the right represents the value 512.
4096=163 256=162 16=161 1=160 2 F 4 D Hexadecimal Number System Base (Radix) 16 Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F e.g. 2F4D16 The digit F in the third position from the right represents the value 3840 and the digit D in the first position from the right represents the value 1.
Binary Arithmetic • Addition • Complements • Subtraction
Binary Addition 0 + 0 0 (b) 0 + 1 1 (a) (c) (d) 1 + 0 1 1 + 1 1 0 Carry Bit
Binary Addition Example 1 • Col 1) Add 1 + 0 = 1 • Write 1 1 1 0 1 1 1 + 0 1 1 1 0 0 • Example 1: Add • binary 110111 to 11100 • Col 2) Add 1 + 0 = 1 • Write 1 • Col 3) Add 1 + 1 = 2 (10 in binary) • Write 0, carry 1 • 1 • 1 • 1 • 1 • Col 4) Add 1+ 0 + 1 = 2 • Write 0, carry 1 • Col 5) Add 1 + 1 + 1 = 3 (11 in binary) • Write 1, carry 1 • Col 6) Add 1 + 1 + 0 = 2 • Write 0, carry 1 • 1 • 0 • 1 • 0 • 0 • 1 • 1 • Col 7) Bring down the carried 1 • Write 1
Binary Addition Verification Verification 1101112 5510 +0111002 + 2810 8310 64 32 16 8 4 2 1 1 0 1 0 0 1 1 = 64 + 16 + 2 +1 = 8310 1 1 0 1 1 1 + 0 1 1 1 0 0 • You can always check your • answer by converting the figures to decimal, doing the addition, and comparing the answers. • 1 • 0 • 1 • 0 • 0 • 1 • 1
1011 + 1100 10111 1010 + 100 1110 1011 + 101 10000 101 + 1001 1110 10011001 + 101100 11000101 Binary Addition Examples (a) (b) (c) (d) (e)
Binary Substraction 0 - 0 0 (b) 0 - 1 1 (a) Borrow Bit (c) (d) 1 - 0 1 1 • 1 0
Binary Subtraction Example 1 Col 1) Subtract 1 – 0 = 1 Col 2) Subtract 1 – 0 = 1 Col 3) Try to subtract 0 – 1 can’t. Must borrow 2 from next column. But next column is 0, so must go to column after next to borrow. 1 1 0 0 1 1 - 1 1 1 0 0 • Example 1: Subtract • binary 11100 from 110011 Add the borrowed 2 to the 0 on the right. Now you can borrow from this column (leaving 1 remaining). • 1 • 2 Add the borrowed 2 to the original 0. Then subtract 2 – 1 = 1 • 0 • 0 • 2 • 2 Col 4) Subtract 1 – 1 = 0 Col 5) Try to subtract 0 – 1 can’t. Must borrow from next column. Add the borrowed 2 to the remaining 0. Then subtract 2 – 1 = 1 • 1 • 0 • 1 • 1 • 1 Col 6) Remaining leading 0 can be ignored.
Binary Subtraction Verification 1 1 0 0 1 1 - 1 1 1 0 0 Verification 1100112 5110 - 111002 - 2810 2310 64 32 16 8 4 2 1 1 0 1 1 1 = 16 + 4 + 2 + 1 = 2310 • Subtract binary • 11100 from 110011: • 1 • 2 • 0 • 0 • 2 • 2 • 1 • 0 • 1 • 1 • 1
Binary SubtractionExample 2 Verification 1010012 4110 - 101002 - 2010 2110 64 32 16 8 4 2 1 1 0 1 0 1 = 16 + 4 + 1 = 2110 1 0 1 0 0 1 - 1 0 1 0 0 • Example 2: Subtract • binary 10100 from 101001 • 0 • 2 • 0 • 2 • 1 • 0 • 1 • 0 • 1
Binary Complement (1s Complement) Operation 1 0 0 1 Example 1 1 0 0 1 0 1 1 0 0 0 1 1 0 1 0 0 1
1001110 0110001 + 1 0110010 One’s Complement Two’s Complement Two’s Complement The Two’s complement of a binary number is obtained by first complementing the number and then adding 1 to the result.
Binary Subtraction Binary subtraction is implemented by adding the Two’s complement of the number to be subtracted. Two’s complement of 1001 Example 1101 1101 -1001 +0111 10100 If there is a carry then it is ignored. Thus, the answer is 0100.
Binary Codes A binary code is a group of n bits that assume up to 2n distinct combinations of 1’s and 0’s with each combination representing one element of the set that is being coded. • BCD – Binary Coded Decimal • ASCII – American Standard Code for Information Interchange
BCD – Binary Coded Decimal Decimal BCD Number Number 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 When the decimal numbers are represented in BCD, each decimal digit is represented by the equivalent BCD code. Example :BCD Representation of Decimal 6349 6 3 4 9 0110 0011 0100 1001
ASCII Number ASCII Letter ASCII 0 0110000 1 0110001 2 0110010 3 0110011 4 0110100 5 0110101 6 0110110 7 0110111 8 0111000 9 0111001 A 1000001 B 1000010 C 1000011 D 1000100 E 1000101 F 1000110 G 1000111 H 1001000 I 1001001
ASCII Continued. Letter ASCII Letter ASCII J 1001010 K 1001011 L 1001100 M 1001101 N 1001110 O 1001111 P 1010000 Q 1010001 R 1010010 S 1010011 T 1010100 U 1010101 V 1010110 W 1010111 X 1011000 Y 1011001 Z 1011010
Logic Gates • Binary information is represented in digital computers by physical quantities called signals. • Two different electrical voltage levels such as 3 volts and 0.5 volts may be used to represent binary 1 and 0. • Binary logic deals with binary variables and with operations that assume a logical meaning.
Logic Gates Contd… • A particular logic operation can be described in an algebraic or tabular form. • The manipulation of binary information is done by the circuits called logic gates which are blocks of hardware that produce signals of binary 1 or 0 when input logic requirements are satisfied.
Logic Gates Contd… • Each gate has a distinct graphics symbol and it’s operation can be described by means of an algebraic expression or in a form of a table called the truth table. • Each gate has one or more binary inputs and one binary output.
Logic Gates AND OR NOT (Inverter) NAND (Not AND) NOR (Not OR) XOR (Exclusive-OR) Exclusive-NOR
A x A B x 0 0 0 0 1 0 1 0 0 1 1 1 B Logic GatesCont. AND Logic Gate Truth Table x = A . B A, BBinary Input Variables xBinary Output Variable
A B x 0 0 0 0 1 1 1 0 1 1 1 1 A x B Logic Gates Cont. OR Logic Gate Truth Table x = A + B This is read as x equals A or B.
x A Logic GatesCont. NOT Logic Gate Truth Table A x 0 1 1 0 x = A
A B x 0 0 1 0 1 1 1 0 1 1 1 0 A x B Logic Gates Cont. NAND Logic Gate Truth Table x = A . B
A B x 0 0 1 0 1 0 1 0 0 1 1 0 A x B Logic Gates Cont. NOR Logic Gate Truth Table x = A + B
A x B x = A + B Logic Gates Cont. XOR Logic Gate Truth Table A B x 0 0 0 0 1 1 1 0 1 1 1 0
A B x 0 0 1 0 1 0 1 0 0 1 1 1 A x B Logic Gates Cont. Exclusive-NOR Logic Gate Truth Table x = A + B