Professional Documents
Culture Documents
Fall 2019
2 Outline
Numeral System
Decimal System
Binary System
Octal System
Hexadecimal System
Digit and Positions
Bits, Bytes & Words
Conversions
Negative Numbers
Boolean Logic Operations
11/11/2019
Numeral System
3
11/11/2019
4 Base/Radix of Numeral System
The number of distinct symbols that can be used to represent
numbers in that system.
For example, the base for the „decimal numerical symbol is 10‟,
as we can use the ten symbols 0,1,2,…,9 to represent numbers
in this system.
11/11/2019
5 Decimal Number System
The decimal numeral system (base ten or denary) has
ten as its base. It is the numerical base most widely used
by modern civilizations.
11/11/2019
Binary Number System
6
The binary numeral system (base two) has two as its base.
It is the numerical base used by the modern day computers where
numbers need to be stored using the on/off logic of electronic and/or
magnetic media. The ON and OFF conveniently translate into 1 and 0.
11/11/2019
7 Octal Number System
base eight) has eight as its base.
The octal numeral system (
11/11/2019
Hexadecimal Number System
8
The hexadecimal numeral system (base 16) has sixteen as its base.
This system uses the 16 symbols: {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
The main advantage of using this numeral system is that it keeps the
representations short, and hence manageable.
For example: the decimal number 199834, is represented in binary as
110000110010011010; and in hexadecimal as 30C9A.
11/11/2019
9
Why we need all these systems
11/11/2019
10 Digit & Position
The length of a representation grows, from right to left, like: 0,1, 2, 3, … so
on.
Let‟s take the example of the decimal system.
The number nine, in decimal, consists of one digit „9‟ at position 0.
Similarly, all the numbers 0, 1, 2…,9 all consist of a single digit at position 0.
But once we reach 9, we have run out of new symbols (in decimal system) and
hence we must increase the length.
Therefore we add another digit to the left, at position 1. Hence we get 10,
11,12…,19,20,21,…,99.
when again, we run out of all length-two combinations of symbols and must proceed
to length-three representations, starting from 100, so on.
11/11/2019
Digit & Position
11
dn-1 … d3 d2 d1 d0
So for the number 199834, in decimal, d0=4, d1=3, d2=8, d3=9,
d4=9 and d5=1.
In general, We call the rightmost digit, d0, the least significant
digit (LSB)
and the leftmost digit dn-1, the most significant digit (MSB).
11/11/2019
BITS, BYTES and WORDS
12
A digit in the binary system is more commonly called a bit.
Therefore, a bit is a single digit in the binary representation of a
number and is either 0 or 1.
When a binary number is represented using 8 bits, the resulting
representation, composed of d0, d1, d2… d7, is called a byte.
Similarly a binary representation composed of 16 bits is called a
word,
a binary representation composed of 32 bits is called a double
word,
and a binary representation composed of 64 bits is called a
quadruple word.
11/11/2019
BITS, BYTES and WORDS
13
11/11/2019
BITS, BYTES and WORDS
14
Decimal Octal
Binary Hexadecimal
11/11/2019
Quantities/Counting (1 of 3)
Hexa-
Decimal Binary Octal decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
Quantities/Counting (2 of 3)
Hexa-
Decimal Binary Octal decimal
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Quantities/Counting (3 of 3)
Hexa-
Decimal Binary Octal decimal
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17
Quick Example
11/11/2019
Decimal to Decimal (just for fun)
Decimal Octal
Binary Hexadecimal
11/11/2019
Weight
Base
11/11/2019
Binary to Decimal
Decimal Octal
Binary Hexadecimal
11/11/2019
Binary to Decimal
Technique
Multiply each bit by 2n, where n is the “weight” of the bit
The weight is the position of the bit, starting from 0 on the
right
Add the results
11/11/2019
Example
Bit “0”
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
11/11/2019
Octal to Decimal
Decimal Octal
Binary Hexadecimal
11/11/2019
Octal to Decimal
Technique
n
Multiply each bit by 8 , where n is the “weight” of
the bit
The weight is the position of the bit, starting from 0 on
the right
Add the results
Example
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Decimal
Technique
Multiply each bit by 16n, where n is the “weight” of
the bit
The weight is the position of the bit, starting from 0 on
the right
Add the results
Example
Decimal Octal
Binary Hexadecimal
Decimal to Binary
Technique
Divide by two, keep track of the remainder
First remainder is bit 0 (LSB, least-significant bit)
Second remainder is bit 1
Example
2 125
12510 = ?2
2 62 1
2 31 0
15 1
2
7 1
2
2 3 1
2 1 1
0 1
12510 = 11111012
Octal to Binary
Decimal Octal
Binary Hexadecimal
Octal to Binary
Technique
Convert each octal digit to a 3-bit equivalent
binary representation
Example
7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
Decimal Octal
Binary Hexadecimal
Hexadecimal to Binary
Technique
Convert each hexadecimal digit to a 4-bit
equivalent binary representation
Example
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Decimal to Octal
Decimal Octal
Binary Hexadecimal
Decimal to Octal
Technique
Divide by 8
Keep track of the remainder
Example
123410 = ?8
8 1234
8 154 2
8 19 2
8 2 3
0 2
123410 = 23228
Decimal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Decimal to Hexadecimal
Technique
Divide by 16
Keep track of the remainder
Example
123410 = ?16
16 1234
16 77 2
16 4 13 = D
0 4
123410 = 4D216
Binary to Octal
Decimal Octal
Binary Hexadecimal
Binary to Octal
Technique
Group bits in threes, starting on right
Convert to octal digits
Example
10110101112 = ?8
1 3 2 7
10110101112 = 13278
Binary to Hexadecimal
Decimal Octal
Binary Hexadecimal
Binary to Hexadecimal
Technique
Group bits in fours, starting on right
Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
Octal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Octal to Hexadecimal
Technique
Use binary as an intermediary
Example
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
Hexadecimal to Octal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Octal
Technique
Use binary as an intermediary
Example
1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
33
1110101
703
1AF
11/11/2019
Negative Number
64
11/11/2019
65
Signed Magnitude
Use the leftmost digit as a sign indication,
and treat the remaining bits as if they represented an
unsigned integer.
The convention is that if the leftmost digit (most significant
bit) is 0 the number is positive,
if it‟s 1 the number is negative.
00001010 = decimal 10
10001010 = decimal -10
11/11/2019
Signed Magnitude
66
11/11/2019
67
1’s Complement
To obtain one‟s complement, you simply need to flip all the bits.
Suppose we are working with unsigned integers.
Decimal 10 is represented as: 00001010
It‟s one complement would be: 11110101
Notice that the complement is 245, which is 255 – 10.
That is no co-incidence.
The complement of a number is the largest number represented with the
number of bits available minus the number itself.
Since we are using 8 bits here the maximum number represented is 255 (2^8 – 1). So
the complement of 10 will be 245.
11/11/2019
1’s Complement
68
11/11/2019
72
11/11/2019
Number Overflow
73
11/11/2019
74
Number Overflow
Overflow occurs when the value that we compute cannot fit into
the number of bits we have allocated for the result.
For example, if each value is stored using eight bits, adding127 to 3
would produce an overflow:
11/11/2019
Boolean Logic Operations
Let x, y, z be Boolean variables.
0 1
Off On
Low High
False True
We define the following logic operations or
functions among the Boolean variables
x y = x´
0
1
Truth Table for the NOT Operation
x y = x´
0 1
1 0
Truth Table for the AND Operation
(z true when both x & y true)
x y z=x·y
0 0
0 1
1 0
1 1
Truth Table for the AND Operation
x y z=x·y
0 0 0
0 1 0
1 0 0
1 1 1
Truth Table for the OR Operation
(z true when x or y or both true)
x y z=x+y
0 0
0 1
1 0
1 1
Truth Table for the OR Operation
x y z=x+y
0 0 0
0 1 1
1 0 1
1 1 1
Truth Table for the XOR Operation
(z true when x or y true, but not both)
x y z=xy
0 0
0 1
1 0
1 1
Truth Table for the XOR Operation
x y z=xy
0 0 0
0 1 1
1 0 1
1 1 0
Those 4 were the fundamental logic operations. Here are
examples of a few more complex situations
z = (x + y)´
z = y · (x + y)
z = (y · x) w
11/11/2019