Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Number Systems
Credits:
Slides adapted from:
J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006
C.H. Roth, Fundamentals of Logic Design, 5/e, Thomson, 2004
1
Positional Number Systems
3
Octal and Hexadecimal Numbers
4
Conversion from Binary to Decimal
p -1
Method: summation B i
b
i - n
2 i
Example:
101110110012 = 1 210 + 0 29 + 1 28 + 1 27 + 1 26 + 0 25 +
1 24 + 1 23 + 0 22 + 0 21 + 1 20 = 149710
5
Conversion from Decimal to Binary
Example:
6
EXAMPLE: convert 5310 to binary
7
EXAMPLE: convert .625ten to binary
8
EXAMPLE: convert 0.710 to binary.
9
EXAMPLE: convert 231.34 to base 7.
10
Addition of Binary Numbers
11
Subtraction of Binary Numbers
EXAMPLES:
12
Representation of Negative Numbers
Signed-Magnitude Representation
+10ten -10ten
001010two 101010two
Radix-complement Representation
The complement of an n-digit number D is obtained by
subtracting it from rn
rn – D = ((rn-1)-D) + 1
16
Complement Number Systems
17
Complement Number Systems
Once we know how to compute the diminished-radix
complement of a number, computing the radix-complement
is very simple:
0
9 1
8 2
7 3
6 4 18
5
C2 Number System
19
Two’s Complement Number System
-8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7
0
-1 1
0000
1111 0001 2
-2
1110 0010
-3 3
1101 0011
-4 4
1100 0100
5
1011 0101
-5
1010 0110
-6 1001 6
1000 0111 20
-7 -8 7
C1 Number System
22
C1 Number System
In the C1 number system to negate an n-bit number all we
have do is to flip (invert) all the bits
23
C2 Number System
24
“Playing” with the C2 notation
X + X -1 X + 1 -X X + X + 1 0
25
C2 EXAMPLES
26
C2 sign extension
27
C2 Addition and Subtraction
28
C2 Addition and Subtraction
29
C2 Addition and Subtraction
30
Detecting overflow
Overflow occurs when the value affects the sign bit:
adding two positives yields a negative
adding two negatives gives a positive
subtract a negative from a positive and get a negative
subtract a positive from a negative and get a positive
No overflow when adding a positive and a negative number
No overflow when subtracting two numbers of same sign
32
Gray Code
33
Character Codes
34
N-cubes and Hamming distance
35
Traversing a 3-cube in Gray code order
36