decimal number system
DESCRIPTION
1000. 100. 10. 1. 7. 4. 7. 5. Decimal Number System. Base (Radix)10 Digits0, 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. - PowerPoint PPT PresentationTRANSCRIPT
©zaher elsir Sudan Academy for Banking & Financial Sciences
Decimal Number SystemBase (Radix) 10Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9e.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.
7
1000 100
4 7 5
110
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Number SystemBase (Radix) 2Digits 0, 1e.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.
1
8=23
1 1 0
4=22 2=21 1=20
©zaher elsir Sudan Academy for Banking & Financial Sciences
Octal Number SystemBase (Radix) 8Digits 0, 1, 2, 3, 4, 5, 6, 7e.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.
1
512=83
6
64=82
2
8=81
3
1=80
©zaher elsir Sudan Academy for Banking & Financial Sciences
Hexadecimal Number SystemBase (Radix) 16
Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
e.g. 2F4D 16
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.
2
4096=163
F
256=162
4
16=161
D
1=160
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Arithmetic
• Addition
•Complements
•Subtraction
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Addition 0+ 0 0
0+ 1 1
1+ 0 1
1+ 11 0
Carry Bit
(a) (b)
(c) (d)
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Addition Example 1
1 1 0 1 1 1
+ 0 1 1 1 0 0
–1
–1
–1–1–1
–0–1–0–0 –1–1
–Example 1: Add
–binary 110111 to 11100
– Col 1) Add 1 + 0 = 1– Write 1
– Col 2) Add 1 + 0 = 1– Write 1
– Col 3) Add 1 + 1 = 2 (10 in binary)– Write 0, carry 1
– Col 4) Add 1+ 0 + 1 = 2– Write 0, carry 1
– Col 6) Add 1 + 1 + 0 = 2– Write 0, carry 1
– Col 5) Add 1 + 1 + 1 = 3 (11 in binary)– Write 1, carry 1
– Col 7) Bring down the carried 1– Write 1
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Addition VerificationVerification
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
–1–0–1–0–0 –1–1
–You can always check your –answer by converting the figures to decimal, doing the addition, and comparing the answers.
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Addition Examples
10011001+ 101100 11000101
101 + 1001 1110
1011 + 101 10000
1010 + 100 1110
1011 + 1100 10111
(a) (b) (c)
(d) (e)
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Substraction 0
- 0 0
0- 1 1
1- 0 1
1- 1 0
Borrow Bit
(a) (b)
(c) (d)
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Subtraction Example 1
1 1 0 0 1 1
- 1 1 1 0 0
–Example 1: Subtract–binary 11100 from 110011
–2–0–0–2
–1–2
–1–1–0–1
Col 1) Subtract 1 – 0 = 1
Col 5) Try to subtract 0 – 1 can’t.
Must borrow from next column.
Col 4) Subtract 1 – 1 = 0
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. Add the borrowed 2 to the 0 on the right.
Now you can borrow from this column
(leaving 1 remaining).
Col 2) Subtract 1 – 0 = 1
Add the borrowed 2 to the original 0.
Then subtract 2 – 1 = 1
–1 Add the borrowed 2 to the remaining 0.
Then subtract 2 – 1 = 1Col 6) Remaining leading 0 can be ignored.
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Subtraction Verification
Verification
1100112 5110
- 111002 - 2810
2310
64 32 16 8 4 2 1
1 0 1 1 1
= 16 + 4 + 2 + 1
= 2310
1 1 0 0 1 1
- 1 1 1 0 0
–2–0–0–2
–1–2
–1–1–0–1 –1
–Subtract binary –11100 from 110011:
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary SubtractionExample 2
1 0 1 0 0 1
- 1 0 1 0 0
–Example 2: Subtract–binary 10100 from 101001
–2–0 –0–2
–1–1–0–1 –0
Verification
1010012 4110
- 101002 - 2010
2110
64 32 16 8 4 2 1
1 0 1 0 1
= 16 + 4 + 1
= 2110
©zaher elsir Sudan Academy for Banking & Financial Sciences
Example
1 1 0 0 1 0 1 1 0
0 0 1 1 0 1 0 0 1
Binary Complement
(1s Complement) Operation
1 00 1
©zaher elsir Sudan Academy for Banking & Financial Sciences
Two’s ComplementThe Two’s complement of a binary number is obtained by first complementing the number and then adding 1 to the result.1001110
0110001+ 1
0110010
One’s Complement
Two’s Complement
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary SubtractionBinary subtraction is implemented by adding the Two’s complement of the number to be subtracted.
Example
1101 1101 -1001 +0111
10100
If there is a carry then it is ignored. Thus, the answer is 0100.
Two’s complement of 1001
©zaher elsir Sudan Academy for Banking & Financial Sciences
Binary Codes
• BCD – Binary Coded Decimal
• ASCII – American Standard Code for Information Interchange
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.
©zaher elsir Sudan Academy for Banking & Financial Sciences
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
©zaher elsir Sudan Academy for Banking & Financial Sciences
ASCII
001100001
01100012
01100103
01100114
01101005
01101016
01101107
01101118
01110009
0111001
Number ASCII Letter ASCII
A1000001B
1000010C
1000011D
1000100E
1000101F
1000110G
1000111H
1001000I
1001001
©zaher elsir Sudan Academy for Banking & Financial Sciences
ASCII Continued.
J1001010K
1001011L
1001100M
1001101N
1001110O
1001111P
1010000Q
1010001R
1010010
Letter ASCII Letter ASCIIS
1010011T
1010100U
1010101V
1010110W
1010111X
1011000Y
1011001Z
1011010
©zaher elsir Sudan Academy for Banking & Financial Sciences
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.
©zaher elsir Sudan Academy for Banking & Financial Sciences
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.
©zaher elsir Sudan Academy for Banking & Financial Sciences
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.
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates ANDOR NOT (Inverter)NAND (Not AND)NOR (Not OR)XOR (Exclusive-OR)Exclusive-NOR
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates Cont.
AND Logic Gate Truth Table
A
Bx
A B x0 0 00 1 01 0 01 1 1A, B Binary Input Variables
x Binary Output Variable
x = A . B
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates Cont. OR Logic Gate Truth Table
A B x0 0 00 1 11 0 11 1 1
A
Bx
x = A + B
This is read as x equals A or B.
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates Cont.
NOTLogic Gate Truth Table
A x 0 1 1 0
xA
x = A
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates Cont. NAND Logic Gate Truth
Table
A B x0 0 10 1 11 0 11 1 0
A
Bx
x = A . B
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates Cont. NORLogic Gate Truth
TableA B x0 0 10 1 01 0 01 1 0
A
Bx
x = A + B
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates Cont. XORLogic Gate Truth
TableA B x0 0 00 1 11 0 11 1 0
A
Bx
x = A + B
–© zaher elsir –Sudan Academy for Banking & Financial Sciences
Logic Gates Cont.
Exclusive-NOR Logic Gate Truth Table
A B x0 0 10 1 01 0 01 1 1
A
Bx
x = A + B