Professional Documents
Culture Documents
1.number Systems
1.number Systems
1
Dr. Mohammed Najm Abdullah
The decimal number system has a base of 10.
2
Dr. Mohammed Najm Abdullah
Binary Numbers
The binary number system is another way to represent quantities. It is less
complicated than the decimal system because it has only two digits. The decimal
system with its ten digits is a base-ten system; the binary system with its two digits
is a base-two system. The two binary digits (bits) are I and O. The position of a 1
or 0 in a binary number indicates its weight, or value within the number, just as the
position of a decimal digit determines the value of that digit. The weights in a
binary number are based on powers of two.
Counting in Binary
3
Dr. Mohammed Najm Abdullah
The Weighting Structure of Binary Numbers
A binary number is a weighted number. The right-most bit is the LSB
(least significant bit) in a binary whole number and has a weight of 20 =
1. The weights increase from right to left by a power of two for each bit.
The left-most bit is the MSB (most significant bit); its weight depends
on the size of the binary number.
The weight structure of a binary number is:
Binary-to-Decimal Conversion
The decimal value of any binary number can be found by adding the
weights of all bits that are 1 and discarding the weights of all bits that
are 0.
4
Dr. Mohammed Najm Abdullah
DECIMAL- TO-BINARY CONVERSION
1. Sum-of-Weights Method
5
Dr. Mohammed Najm Abdullah
2. Repeated Division-by-2 Method
Ex:
6
Dr. Mohammed Najm Abdullah
Converting Decimal Fractions to Binary
Homework:
BINARY ARITHMETIC
1. Binary Addition
7
Dr. Mohammed Najm Abdullah
2. Binary Subtraction
8
Dr. Mohammed Najm Abdullah
3. Binary Multiplication
9
Dr. Mohammed Najm Abdullah
4. Binary Division
Division in binary follows the same procedure as division in
decimal. The following example illustrates. The equivalent
decimal divisions are also given.
Homework:
10
Dr. Mohammed Najm Abdullah
1'S AND 2'S COMPLEMENTS OF BINARY NUMBERS
Finding the 1's Complement
11
Dr. Mohammed Najm Abdullah
An alternative method of finding the 2's complement of a binary number
is as follows:
1. Start at the right with the LSB and write the bits as they are up to
and including the first 1.
2. Take the 1's complements of the remaining bits.
12
Dr. Mohammed Najm Abdullah
HEXADECIMAL NUMBERS
Counting in Hexadecimal
10,11, 12,13,14,15, 16, 17, 18, 19, lA, IB, 1C, ID, IE, IF,
20, 21, 22, 23, 24, 25,26,27,28,29, 2A, 2B, 2C, 2D, 2E,
2F, 30, 31,. . .
13
Dr. Mohammed Najm Abdullah
Binary-to-Hexadecimal Conversion
Hexadecimal-to-Binary Conversion
14
Dr. Mohammed Najm Abdullah
Hexadecimal-to-Decimal Conversion
15
Dr. Mohammed Najm Abdullah
Decimal-to-Hexadecimal Conversion
Hexadecimal Addition
16
Dr. Mohammed Najm Abdullah
Hexadecimal Subtraction
17
Dr. Mohammed Najm Abdullah
18
Dr. Mohammed Najm Abdullah
OCTAL NUMBERS
The octal number system is composed of eight digits,
which are
0, 1, 2, 3, 4, 5, 6, 7
To count above 7, begin another column and start
over:
10, 11, 12, 13, 14, 15, 16, 17, 20, 21, ...
Octal-to-Decimal Conversion
19
Dr. Mohammed Najm Abdullah
Decimal-to-Octal Conversion
Octal-to-Binary Conversion
20
Dr. Mohammed Najm Abdullah
Binary-to-Octal Conversion
21
Dr. Mohammed Najm Abdullah
BINARY CODED DECIMAL (BCD)
The 8421 Code
22
Dr. Mohammed Najm Abdullah
BCD Addition
Step 1: Add the two BCD numbers, using the rules for
binary addition
Step 2: If a 4-bit sum is equal to or less than 9, it is a
valid BCD number.
Step 3. If a 4-bit sum is greater than 9, or if a carry out
of the 4-bit group is generated, it is an invalid
result. Add 6 (0110) to the 4-bit sum in order
to skip the six invalid states and return the
code to 8421. If a carry results when 6 is
added, simply add the carry to the next 4-bit
group.
23
Dr. Mohammed Najm Abdullah
24
Dr. Mohammed Najm Abdullah
25
Dr. Mohammed Najm Abdullah
DIGITAL CODES
The Gray Code
26
Dr. Mohammed Najm Abdullah
Gray-to-Binary Conversion
1. The most significant bit (left-most) in the binary
code is the same as the corresponding bit in the
Gray code.
2. Add each binary code bit generated to the Gray
code bit in the next adjacent position. Discard
carries.
27
Dr. Mohammed Najm Abdullah
28
Dr. Mohammed Najm Abdullah
Alphanumeric Codes
ASCII
29
Dr. Mohammed Najm Abdullah
30
Dr. Mohammed Najm Abdullah