Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Outline
Generic Number Systems
Decimal, Binary, Octal, and
Hexadecimal
Conversion Between Number
Systems
Addition in base-b
Representing ve numbers in
binary format
2
NUMBER SYSTEMS
A number with base b is represented by a string of digits:
6 4 8 4 . 3 9 4
Decimal
Binary
Octal
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
01101
01110
01111
10000
00
01
02
03
04
05
06
07
10
11
12
13
14
15
16
17
20
Hexadeci
mal
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
5
Digit Weight
Base
Symbols
-5
-4
-3
-2
Digit
-1
Position
0
1
2
3
Genera
l
Decimal
Binary
Octal
10
0 => b
-1
0 => 9
0 => 1
0 => 7
b-5
b-4
b-3
b-2
b-1
b0
b1
b2
b3
b4
b5
10-5 =
0.00001
10-4 =
0.0001
10-3 =
0.001
10-2 =
0.01
10-1 = 0.1
100 = 1
101 = 10
2-5 =
0.03125
2-4 =
0.0625
2-3 =
0.125
2-2 = 0.25
2-1 = 0.5
20 = 1
21 = 2
22 = 4
8-5 = 1/
(8)5
8-4 = 1/
(8)4
8-3 = 1/
(8)3
8-2
=0.01563
8-1=
0.125
80= 1
1
Exercise
What is the value a) 5 x 10
of digit 5 in octal
b) 5 x 82
number 4578?
c) 5 x 8
d) 5 x 2
What is the
value of digit 2
in number
433.125
a) 2
b) 2 x 2-1
c) 2 x 10-2
d) 2 x 5-2
Decimal Counting
0
1
2
3
4
5
6
7
8
9
10
11
12
13
.
.
.
.
98
99
100
101
102
103
.
.
.
.
998
999
1000
1001
1002
1003
.
.
.
.
9998
9999
Octal Counting
0
1
2
3
4
5
6
7
10
11
12
13
.
.
76
77
100
101
102
103
.
.
776
777
1000
1001
1002
1003
.
.
7776
7777
Binary Counting
1000
1001
1010
1011
1100
1101
1110
1111
10
Exercises
In Binary number
system, what
comes after 1010
?
a) 1110
b) 1011
c) 1001
d) 1101
In Hexadecimal
number system,
what comes
after CDF?
a) CDF1
b) CDF0
c) CE0
d) CD0
11
Exercises
Convert 3041.2315 to decimal
13
Example
Convert the decimal number 325.512 to
base-5
Number
Division
Remainder
325
65
13
325 / 5 = 65
65 / 5 = 13
13 / 5 = 2
0
0
3
2/5=0
Fraction
Multiplication
Whole Number
0.512
0.512 x 5 =
2.56
0.56
0.56 x 5 = 2.8
0.8
0.8 x 5 = 4.0
Answer: 325.51210 = 2300.2245
2
4
15
16
17
Exercises
Convert the decimal number 95.12510 to
binary
18
. 4
2
19
. 4
111001010. 100011
20
8
21
101000011100. 01001011
22
Exercises
Convert the Binary number
110101010.101010 to Hex
23
Homework
Complete the following table:
Decimal
Binary
Octal
Hexadeci
mal
11011011.
101
3672.672
528.625
AB9.CD
24
Special Power of 2
25
Number Range
Given N-digit decimal number
You can represent up to 10N possible values
Range is: [0, 10N - 1]
Example
A 3-digit decimal number represents 103 = 1000
possible values,
Range [0, 999]
27
Exercises
How many bits are required to represent
64G in base 2?
28
Addition in base-b
To add two numbers in base b, do a
repetitive summation starting from the
two least significant digits.
If the sum is r, set sum = sum - b and
set the carry out to 1, otherwise the
carry
Examplout = 0.
es
Co
Su
m
1100
Co
1110
A 938
0110
C A9 7
1111
173CF
Su
m
10101
29
Exercises
What is the result of : 0101112 + 1010112
?
30
31
Sign/Magnitude
1 sign bit, N-1 magnitude bits
Sign bit is the most significant bit (left most)
Negative number: sign bit = 1
Positive number: sign bit = 0
Range of an N-bit sign/magnitude number:
[-2N-1 + 1, 2N-1 - 1]
Problems
Two representations of zero [0000, 1000]
Difficulties in arithmetic operations:
1101 (-5) + 0011 (3) = 0000
32
Exercises
Represent 27 in sign/magnitude format
33
Unsigned:
10110 = 16 + 4 + 2 =
22
Twos complement
10110 = -16 + 4
+ 2 = -10
Single
representation of
zero (0000)
Arithmetic works
fine
34
First
meth
od
Complement each
digit to get the first
complement
100101
100110
Secon
d
Metho
d
011010
100110
35
Exercises
Represent 27 twos complement format
Homework
Solve the following problems from
your textbook unit 1.4, page 30
37