0% found this document useful (0 votes)
14 views

Numbering System 1

Uploaded by

Nour Radwan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Numbering System 1

Uploaded by

Nour Radwan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/343361645

Chapter One: Numbering System

Chapter · August 2020

CITATIONS READS

0 1,644

1 author:

Qasim Mohammed Hussein


Tikrit University
86 PUBLICATIONS 72 CITATIONS

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Correlation between Cumulative Exposure to Lead Metal with Obesity and Related Conditions such Diabetic and Hypertention View project

Computer Vision and Image Analysis, Understanding and Processing View project

All content following this page was uploaded by Qasim Mohammed Hussein on 01 August 2020.

The user has requested enhancement of the downloaded file.


Chapter 1: Numbering system

Numbering system
Objective
 Understand the decimal, binary, octal and
hexadecimal number systems.
 Convert from one number system into another.
 Apply arithmetic operations to binary numbers.
 Understand binary codes and alpha numeric codes.

1.1 Types of Numbering systems


A number system defines a set of values to represent
quantity. There are many numbering systems used in
the real world. Each of these systems has its base (or
radix). The base means the number of symbols that are
used in the system, and it is indicated by a subscript.
The position of each digit in the number indicates the
magnitude of the quantity represented and can be
assigned as a weight. The weights are increased from
right to left, beginning with power 0 of the base. While
the fractional number weight start from left to right,
starting with power -1, -2, -3…etc.
Page 1
Chapter 1: Numbering system

For example in decimal number:


. . . 103 102 101 100 . 10-1 10-2 10-3 10 -4 . . .
Decimal point
1.1.1 Decimal systems
Peoples have familiarity with the decimal number
system because they use it every day. The decimal
number system has a base of 10. The ten symbols
(digits) are 0 through 9. The weight of a digit, value, in
the number is determined by its position.

Example A1: Find the decimal number of 286 as a sum


of the values of each digits?
Solution
1 0
286 = (2x102) + (8 x 10 ) + (6 x 10 )
= (2x100) + (8 x 10) + (6 x1)
= 200+ 80 + 6
= (286)10

Page 2
Chapter 1: Numbering system

1.1.2 Binary system


The digital codes and binary number system are
fundamental to computers. The system of binary
number has a base of 2. It uses two symbols, 1 and 0.
Each of the two digits is called a bit (binary digit). For
example the number (1000110) is accepted in binary
system, while the number (1100200) is not accepted
because there is the digit 2. The counting in binary
system start from 0 ,1 then take two digits 00,01,10,11
and three digit and so on.
In weighting of binary number, the least significant bit
(LSB) has the weight 20=1. The weight increases from
LSB to most significant bit (MSB) by power of two for
each digit. For example:

1.1.3 Octal system


The octal number system has a base of 8. The symbols
that use are 0, 1, 2, 3, 4, 5, 6 and 7. In other words, any
number is not accepted in octal system if there is a digit

Page 3
Chapter 1: Numbering system

value more than 7. The counting in octal system starts


from 0 and increments by 1 until 7, then the number
contains two digits: 7+1= 10, 10+1= 11, 11+1= 12.

1.1.4 Hexadecimal system


The base of this system is 16. It is composed of 16
numeric and alphabetic characters. It consists of digit 0,
1, 2, 3, 4, 5, 6, 7, 8, 9 and letters A, B, C, D, E, F. The
letters A, B, C, D, E and F are used to represent the
digits 10, 11, 12, 13, 14 and 15.
Since the hexadecimal number is very convenient to
represent groups of 4 bits, it is the most common
system seen today in representing raw data computer
data. Each single hexadecimal digit can be represented
by four digits in a binary number. This makes
conversion between binary and hexadecimal numbers
easy, and hexadecimal can be represented with much
fewer digits to write large binary numbers. When
someone working with computers, it is common to find
binary numbers with 8, 16 and may be 32 digits.

Page 4
Chapter 1: Numbering system

Writing a 16 or 32 bit binary number would be caused a


quite tedious and error prone. So, by using the
hexadecimal, one can write the numbers with fewer
digits and much less probability of occurrence of the
error.
Note:
For discrimination between numbers with different
bases, the coefficients is enclosed in parentheses and
write a subscript equal to base that is used.
(8265)10 , (1092)10  Decimal numbers
(10110)2, (100.01)2  Binary numbers
(2751)8, (1763.56)8  Octal numbers
(A926)16, (15B.CF)16  Hexadecimal numbers

1.2 Number systems conversion


The systems number can be converted from one system
to another system to be able to use the appropriate
numbering system that suitable for a particular
application, as discussions below.

Page 5
Chapter 1: Numbering system

1.2.1 Decimal number to other systems number


conversion
The number may include two parts: integer part and
fraction part. Each part in the number is converted from
one system to other separately.
To convert a given integer part of decimal number to
other number in systems, such as binary, octal, and
hexadecimal is down by the following steps:
(a) Divide the decimal number by r, where r is the base
of the others system.
(b) Write the remainder (one of base symbols) at the
rightmost position.
(c) Repeat the procedure of dividing the quotient by r
until the quotient becomes 0 and keep track the
remainder at each step of division.
(d) Concatenate the remainders together starting from
the last one to give the equivalent other system
number.

Page 6
Chapter 1: Numbering system

Table A1 illustrates the conversion of decimal numbers


to their equivalent binary, octal and hexadecimal
numbers.
Table A1: The equivalents in numbering system

Example A2: Convert the number (72)10 to binary,


octal, hexadecimal numbers?
Solution
The solution is done as following:

Page 7
Chapter 1: Numbering system

The resulted number is reading the remainder from


down to top and it is writing from left to right.
Example A3: Convert the number (195)10 to binary,
octal, hexadecimal number?
Solution
(195)10 = (11000011)2
(195)10 = (303)8
(195)10 = (C3)16

Page 8
Chapter 1: Numbering system

To convert the decimal fraction to other system number


is done by the following steps:
a) Multiply the decimal fraction by the base of the
other system, r.
b) If the generated integer is non-zero, take the non-zero
integer otherwise record 0.
c) Ignore the non-zero integer and repeat the above
steps until the value of the fraction becomes 0.
d) According to the occurrence, write down the number.
The first digit represents the most significant digit.

Example A4: Convert (0.375)10 to binary, octal,


hexadecimal number fraction?
Solution
To convert the decimal fraction to binary fraction,
repeat the multiplication by the base of binary system,
the value of r = 2, until to the desire number of digit in
the fraction part or stop when the fraction part is zero.

Page 9
Chapter 1: Numbering system

To octal fraction: 0.375x8 = 3.000 ; Carry 3


(0.375)10 = (0.3)8
To hexadecimal fraction: 0.375x16= 6.000
(0.375)10 = (0.6)16
1.2.2 Other systems to decimal system conversion
Conversion a number from other numbering systems to
decimal number is done by:
a. Put the weight of each digit of the decimal number.
b. Multiply each digit of the number in the other system
by its base power to positional weight.
c. Find the sum of multiplying. The positional weight is
not to be taken into account where the digit is zero.

Page 10
Chapter 1: Numbering system

0
Remember the mathematical rule that n = 1, or any
number raised to the zero power is equal to 1. The
value of decimal number is calculated as follow:

Where r is the base of other numbering system, a is the


value of the digit in the other system, and n is the order
of digit. For example, the number in octal system
(3451.61)8 can found as follow, where r =8 (since the
number in octal):

The value of (3451.61)8


= a3r3+a2r2+a1r1+a0r0+a-1r-1+a-2r-2
= 3x83+4x82+5x81+1x80+6x8-1+1x8-2
= 3x512 + 4x64 + 5x8 + 1x1 + 6x0.125 + 1x0.0156
= 1536 + 256 + 40 + 1 + 0.75+ 0.0156
= (1833.7656)10
Example A5: Convert the following numbers to
decimal number?
Page 11
Chapter 1: Numbering system

a) (1010.01)2
b) (24)8
c) (1A2)16
Solution
a) The weight of each digit :23 22 21 20 2-1 2-2
Binary number :1 0 1 0 . 0 1
(1010.01)2 =8 + 0 + 2+ 0 + 0 + 0.25
= (10.25) 10
b) (27.3)8 = 2 x 81 + 7 x 80 + 3 x (1/8)
= 2x8 + 7x1 + 3x0.125
= 16 + 7 + o.375
= (23.375)10
c) (1A2)16 = 1x162 + 10x161 + 2x160
= 1x256 + 10 x 16 +2
= 256 + 160 + 2 = (418)10
The binary system is the simplest system, so it can be
converted to decimal number by a waiting number. The
weight or value of a binar digit increses from right to
left by a power of 2. The right most bit is the least
significant bit (LSB) in binary number has a weight of
0
2 =1.
Page 12
Chapter 1: Numbering system

The decimal value of any binary number is equal to the


sum of weighting of all bits that are 1. For the fraction
the weighting begins from 2-1 = 0.5 and decreases from
left to right, as shown in below example.
Example A6: Convert (101101.01)2 to decimal
number?
Solution

We can get the same result by using another way to


find the number by summing the weights that
corresponding to values=1, as shown in the following
table:

Page 13
Chapter 1: Numbering system

Example A7: What is the smallest and largest decimal


number that can be represented in binary six bits?
Solution
The smallest binary number is of six bits is (100000)2.
The decimal value of this number is (32)10.
The largest binary number is of six bits is (111111)2.
The decimal value of this number is (63)10.

1.2.3 Binary to octal conversion


The conversions include partition the binary number
into 3-bits group, starting at the left digit of fractional
separator and replace each group with equavelant octal
digit. For the fraction part, the partition is starting from
left to right. The weigth of group digits are 4, 2, 1 (the
weight 1 for LSB digit).

Example A8: Convert (101101.11)2 into octal?


101101 = 101 101 . 110
5 5 6
Thus (101101)2 = (55.6)8.

Page 14
Chapter 1: Numbering system

1.2.4 Binary to hexadecimal conversion.


For the integer part, the conversions include partition
the binary number into group, each group contains 4-
bits. The partition starts from the left digit of fractional
point and replace each group with equavelant
hexadecimal symbol. For the fraction part, the partition
is starting from left to right. The weigth of group digits
are 8, 4, 2, 1 (the weight 1 for LSB digit).

Example A9:
Convert the binary number (10011101101.10101001)2
to hexadecimal number?

Note: If the last group contains less than 4 digits, we


add 0's to the right in integer part, and 0s in left fraction
part. For example (10.101)2 = (0010. 1010)2 = (2.A)16

Page 15
Chapter 1: Numbering system

Example A10: Convert to hexadecimal number the


binary number (10110110)?
Solution
Split into groups for 4 digits : 1011 0110
Conversion each group to hexadecimal digit: B 6
The hexadecimal number : (B6)16

1.2.5 Octal to binary conversion


The coversion is done by replace each octal digit with
equivalent three binary digits. These groups of three
bits are concatenated together to form the binary
number. The simplest conversion by using the weight 4,
2, and 1 for each octal digit.

Example A11: Convert (2701.4)8 to binary number?


Solution
First, convert each digit alone by convert it to three
binary digits and then concatenate them to represent the
binary number.

Page 16
Chapter 1: Numbering system

Octal Weight
digit 4 2 1

2 0 1 0
7 1 1 1
0 0 0 0
1 0 0 1
4 1 0 0

(2701.4)8 = (010111000001.100)2

1.2.6 Hexadecimal to binary conversion


The conversion of hexadecimal number to its
equivalent binary number is done by convert each
hexadecimal digit to its equivalent 4 bits binary
number. Then the hexadecimal digits are concatenated
to constitute the hexadecimal number.

Example A12: Convert (D26.1A)16 to binary number?


Solution:

Page 17
Chapter 1: Numbering system

1.2.7 Conversion between hexadecimal and octal


The conversion process includes the following steps:
a) Split each digit in the octal to 3 –bit binary.
b) Merge all the 3-bit binary numbers.
c) Collect them in 4-bit binary group, starting from
MSB to LSB.
d) Convert each 4-bit group to their hexadecimal digit.

Example A13: Convert (56)8 to hexadecimal number?


Solution
The number (56)8 is an octal number, so each digit will
replaced by three binary digits.
Octal number : 5 6
Binary number: 101 110
Merging the 3-bit binary block, they become 101110.
Grouping them in 4 bit binary form-

Page 18
Chapter 1: Numbering system

The binary number: 0010 1110


The hexadecimal : 2E
The result of (55)8 = (2E)16.
The conversion from hexadecimal number to octal
number is done by reverse the above steps.

Example A14: convert (E27.9) 16 to octal number?

Solution
Hexadecimal number: E 2 7 . 9
Four bit for each digit: 1110 0010 0111 . 1001
Binary number : 111000100111.1001
Divide into 3 bits groups: 111 000 100 111.100 100
Value of each group : 7 0 4 7 4 4
Octal number : (7047.44)8
Example A15: Convert (5B1.7)16 to octal number?
Solution
(5B1.7) 16 = (010110110001.0111)2
=(010110110001.0111)2

= (2661.34)8

Page 19
Chapter 1: Numbering system

Example A16: Convert the octal number (713.5)8 to


hexadecimal number?
Solution
Octal number : 7 1 3 . 5
3 binary digit : 111 001 011 101
Binary number:(111001011.101)2
Four bits group : 0001 1100 1011 . 1010
Value of each group: 1 D B A
Hexadecimal number: (1DB.A)16
The conversions between binary, octal, decimal and
hexadecimal system are illustrated in following figure
(A1).
The conversions between numbering systems can be
summarized in the figure A1.

Page 20
Chapter 1: Numbering system

(a) Conversion between decimal system and other


systems

(b) Conversion between octal system and binary system

Page 21
Chapter 1: Numbering system

(c) Conversion between hexadecimal system and binary


system

(d) Conversion between hexadecimal system and octal


system
Figure (A1): Conversions between numbering systems

Page 22
Chapter 1: Numbering system

3. Binary Arithmetic
Arithmetic operations with number in numbering
system with base r have the same rules in decimal
numbers.
1.3.1 Binary Addition
The binary addition is performed by using the
following the binary table.
0 + 0 = 0  Sum = 0, carry = 0
0+1=1  Sum = 1, carry =0
1+0=1  Sum = 1, carry =0
1+1=0  Sum = 0, carry =1
The carry is found in the same way as in decimal
operation. Since the 1 is the largest digit in the system
of binary. If the sum is greater than 1 need that a digit
be considered overflow, therefore is divided by the
base.
Example A17: Perform the following addition in
binary numbering system?
a) (111)2 + (110)2
b) (1010)2 + (1101)2
c) (11.01)2 + (101.11)2
Page 23
Chapter 1: Numbering system

Solution
11 1 111 1 Carry
111 1010 11.01
110 1101 101.11
------- ------- ----------
1001 10111 1001.00

1.3.2 Binary Subtraction


The binary subtraction is performed like a decimal
number, except borrow is equal 2= (10)2 rather than
(10)10 since the borrow value is equal to the base. The
results of binary subtraction are:
0–0=0
1–0=1
1–1=0
0 – 1 = 1 with a borrow of 1 is equivalent to
2–1=1
Example A18: Perform (111)2 – (010)2 ?
Solution

Page 24
Chapter 1: Numbering system

Example A19: Perform (110.01)2 – (100.10)2?


Solution
need borrow
110.01
100.10
---------
001.11
The second bit from the right need borrow 1 from the
next digit to the left making it value 10 (means 2).
Since the third digit is 0, so it borrow from the forth
digit. So the third column becomes 1. So, the second
digit can able to borrow from the third. The second
digit become 10 (it means 2 in decimal system).
10 – 1 = 1.

1.3.3 Binary multiplication


The binary multiplication is easier that decimal number
multiplication. The result is either 0 or 1. The binary
multiplication table is shown as following:
0x0=0
0x1=0
1x0=0
1x1=1

Page 25
Chapter 1: Numbering system

Example A20: Perform the following?


a) (1011)2 x (110)2
b) (101.01)2 x (11.01)2
Solution
a)

(1011)2 x (110)2 = (1000010)2

b)

(101.01)2 x (11.01)2 =(1001.0001)2

Page 26
Chapter 1: Numbering system

1.3.4 Binary division


The binary division of two digits is as follows.
0÷1=0
1÷1=1
As in the decimal system division by zero is
meaningless.
Example A21: perform
a) (1100)2 ÷ (11)2?
b) (1001)2 ÷ (10)2?

So, the results of the division are:


a) (1100)2 ÷ (11)2 =(100)2;
b) (1001)2 ÷ (10)2 = (100.1)2

1.4. Complements
Complements are used in digital computer for
simplifying the subtraction operations and for logical
manipulations. By the complements, the subtraction of
Page 27
Chapter 1: Numbering system

one number from another is done using only addition of


positive numbers
There are two types of complements in numbering
systems: (r'-1)s complement and r's complements,
which are called true complement and radix-1
complement. In binary system, the complements are 1's
complement and 2's complement are used.

1.4.1 r's complement


For a positive number X with base r and an integer part
contains n digits, the r's complement of X is rn – X for
X≠0. In other word, the r's complement can be found
keep all significant zeros without changed, subtract the
first non-zero digit in least significant from r, and then
subtract from (r-1) all other digit in higher significant.
In the decimal system the r's complement is referred to
10's complement, while in the binary system is referred
to 2's complement. There are following examples of r's
complements.
The 10's complement of (4925)10 is 104 – 4925 = 5075.
The digits number in the 4925 is four, so n=4.
Page 28
Chapter 1: Numbering system

The 10's complement of (0.273)10 is 1 – 0.273 = 0.927


The digits number in the 0.273 is zero, so n=0.
Example A22: find the r's complement of the numbers
(615)8 , (1A280)16, (100100)2 ?

Solution

1.4.2 (r-1)'s complement


For a base r and positive number X with fraction part
of m digits and an integer part of n digits, the (r–1)'s
complement of X is rn – rm – X. In other word, the r's
complement can be found by subtracting all other digits

Example A23:
Find the (r-1)'s complement for the numbers
(1001010)2, (3982)10, (4530)8, (6BE00)16?

Page 29
Chapter 1: Numbering system

Solution

Example A24: Find the 9's complement and 8's


complements for the number (6250)9?
Solution
The 9's complement can be found using r's
complement. It is (2640).
The 8's complement can be found using (r-1)'s
complement. It is (2638).
1.4.3 (1)’s complement
In binary system, the r's complement is called 1's
complement. To find 1’s complement of a binary
number, the 1 is change to 0 and 0 change to 1. In other
word, each digit of the binary number is subtracted
from 1.

Page 30
Chapter 1: Numbering system

Example A25: Find the 1's complement for the


numbers (1010)2, (101101)2, (00011)2 and (110110)2?
Solution
The following table includes the 1's complement of
each the above number .
Binary number 1's Complement
1010 0101
101101 010010
00011 11100
110110 001001

1.4.4 (1)’s complement subtraction:


To subtract M-N, perform the following:
1. Add M number to the 1’s complement of the N
number.
2. According to the result of step 1, if there is end
carry, we add 1 to the digit in least significant (end-
around carry). If there is not end carry, obtain the (r-1)'s
complement of the number getting in step 1 and put a
negative sign in front of it.

Page 31
Chapter 1: Numbering system

Example A26: Perform (7 – 3) using 1's complements


method?
Solution

If there is no carry after add 1 and the leftmost digit is


1, this indicates that the result is a negative and number
will be in its 1’s complement form. So we take the
complement number to get the final result.
100 = (4)10 (after taking 1's complement)
Example A27: Perform 8 – 12 using 1's complements
method?

Taking the 1's complement to the sum result is


(0100)2

Page 32
Chapter 1: Numbering system

The final result is – 4.


1.4.5 2’s Complement
The representation of 2’s complement is used because it
minimize the complexity in the arithmetic-logic unit
hardware in the CPU of the computers. Using the
representation of 2’s complement, all operations of the
arithmetic can be executed using the same hardware
whether the number is signed or unsigned. The
performing of bit operations are similar; the difference
comes from the interpretation of the digits, whether the
value is considered to be signed or unsigned value. The
2’s complement may obtain in many ways, such as:
1. Add 1 to the digit in the least significant of the 1's
complement.
The 2’s complement =1’s complement + 1

Page 33
Chapter 1: Numbering system

2. Keep all the least significant positions with values


0's, the first position with value 1 is unchanged, and
change the values of the rest positions, 1's to 0's and
all 0's to 1.

n
3. Using the form r – N for N ≠ 0, and 0 for N=0.
Where n is the number of digits.

Example A28: The 2's complement is 26- (101100)


= (1000000)2 – (101100)2 = (010100)2
The following table includes some examples about
numbers with their 1's and 2's complement.
Binary 1’s 2’s
Number complement complement
1010 0101 0110
0101 1010 1011
1001 0110 0111
0001 1110 1111

Page 34
Chapter 1: Numbering system

1.4.6 2’s Complement Subtraction


The subtraction in 2's complement of two positive
numbers (M – N) with base 2 is done as following:
1. Keep the first number without change.
2. Write the second number in the 2’s complement
form.
3. Perform the addition of the two numbers.
4. If found a carry, discard it and the sum (remaining
part) will be the result, which is positive.
5. If there is no carry, perform the 2’s complement of
the sum and put negative sign before it, which
become negative result.
Example A29: Subtract using 2's complement?
a) (1000)2 from (1010)2
b) (12)10 from (5)10?
Solution
a) 1010 -----------------> 1010 +
1000 2’s complement 1000
10010
The result is (0010)2.

Page 35
Chapter 1: Numbering system

b) 5 0101 -----------------> 0101 +


12 1100 2’s complement 0100
1001
Take the 2’s complement: - 0111
The result is – 7.
1-5 .1 Signed number
Digital systems have ability to handle the negative and
positive numbers. The signed binary number contains
the sign and magnitude information. The sign refers to
whether the number is negative or positive, it is the
leftmost bit in sign number. The 0 value of the sign bit
indicates that the number is positive, while 1 is
negative. The magnitude represent the number value.
There are three forms of representation the sign binary
number:
1. Sign and magnitude: The leftmost bit of the number
represents the sign bit. The rest bits represent the
magnitude of digits. The magnitude digits of
numbers are the same for both negative and positive
number. For example, (+21)10 = (010101)2, (-
21)10=(110101)2.
Page 36
Chapter 1: Numbering system

2. 1's complement: The positive number represent in


the same way in sign and magnitude form. While
the negative number is founded by performing the
1's complement of the corresponding binary
number. For example
(+28)10 = (011100)2, (-21)10=(100011)2.
Sign bits
3. 2's complement: The positive number represent in
the same way in sign and magnitude form. While
the negative number is founded by taking the 2's
complement of the corresponding binary number.
For example,

(+28)10 = (011100)2, (-21)10= (100100).


Sign bits
Example A30: Represent using 8 bits binary number
the numbers (+39)10 and (-39)10 using sign and
magnitude, 1's complement and 2's complement?

Solution

Page 37
Chapter 1: Numbering system

1.5.1 Floating point number


The floating point number includes two parts with their
sign. The mantissa is the part that represents the
magnitude of the number and its value between 0 and 1.
The exponent is the part that represents the number of
places to be moved. For example, the number 3705100 in
the decimal number can be written as 0.307051 x 107.

1.6 Binary codes


A binary number of n digit may be represented by n
binary circuit elements, each having an output signal
equivalent to a 0 or 1. Digital systems represent and
process not only binary number, but also many other
discrete element of information. Any discrete element
of information among group quantities can be

Page 38
Chapter 1: Numbering system

represented by a binary code. There are many numbers


of binary codes such as: binary coded decimal, excess-
3, (8, 4, -2, -1) codes.

1.6.1 Binary coded decimal (BCD)


In digital system, it is possible to represent decimal
numbers by encoding each digit in binary form in
different codes, one of them is BCD. BCD is a numeric
coding system used to encode each digit of a decimal
number to a 4-bit binary form with weights 8,4,2,1.
There are only ten codes in the BCD codes. The BCD
code 0110 is equal to 6 because 0x8 + 1x4 + 1x2 + 0x1
=6.
Only 10 from 16 patterns are used in BCD. the
remaining 6 patterns not occur in logic operation. They
treated as don't care condition in the design process.
BCD provides a format that is convenient when
numerical information is to be displayed on a simple
digit-oriented display. The drawback of BCD is the

Page 39
Chapter 1: Numbering system

complexity of the circuit that performs arithmetic


operations and wasted 6 possibilities.
Example A31: Convert the following numbers to BCD
code: (136)10, (491)10, (101101)2, (2A3)16?
The solution:

To convert the binary, octal or hexadecimal number to


BCD code, we must convert the number to decimal
system firstly, and the convert the decimal number to
BCD code.
(101101)2 = (45)10 = (0100 0101)BCD
(2A3)16 = (675)10 = (0110 0111 0101)BCD
Example A32: convert the BCD code (1001 0101
0000 0100) to decimal number?
BCD code: 1001 0101 0000 0100
Decimal digit: 9 5 0 4
The decimal number = (9504)10

Page 40
Chapter 1: Numbering system

1.6.2 Excess–3 code


The excess-3 is unweighted code. Excess-3 code
obtains from the corresponding values of BCD after the
addition of 3 (adding 3 for each decimal digit). For
example, the excess-3 of the digit 8 is 1011. Table A2
includes the excess-3 of the decimal digits.
1.6.3 Other codes
It is possible to use a negative weights for a decimal
code such as 8, 4, -2, -1. For example, the code of the
digit (57)10 is (1011 1001).
Or code with weight 2, 4, 2, 1. For example, the code of
digit (57)10 is (0101 1101).
There is a difference between conversion to binary
number and conversion to binary coding although the
result is a series of bits. In binary coding, each digit has
its unique representation, and there is a space between
the representations of adjacent digits. For example,
convert 17 to binary number yields 10001, while to
BCD code yields 0001 0011.

Page 41
Chapter 1: Numbering system

The table A2 illustrates the some binary codes for


decimal digits.
Table A2: binary codes of decimal system

Deci BCD Exces 8 , 4, -2, -


mal code s-3 1 code
digit code
0 0000 0011 0000
1 0001 0100 0111
2 0010 0101 0110
3 0011 0110 0101
4 0100 0111 0100
5 0101 1000 1011
6 0110 1001 1010
7 0111 1010 1001
8 1000 1011 1000
9 1001 1100 1111
Example A34: convert the number (193)10 to
(a) Binary number.
(b) BCD code.
(c) Excess-3 code
(d) 8, 4, -2, -1 code?

Page 42
Chapter 1: Numbering system

Solution
(a) (193)10 = (11000001)2
(b) (193)10 = (0001 1001 0011) in BCD code.
(c) (193)10 = (0100 1100 0110) in excess-3 code.
(d) (193)10 = (0111 1111 0101) in 8,4,-2,-1 code.

Addition in BCD
To add two BCD codes, use the following steps:
1. Add the two BCD numbers like addition in binary
system rules.
2. If the fourth digit, MSB, is less or equal to 9, it is a
accepted in BCD code.
3. If the fourth digit, MSB, is greater than 9, or a carry
out of the fourth digit, it is an unaccepted in BCD
code. We add 6 (0110) to the sum of addition
operation in order to skip the six invalid codes and
return the code to the weight 8,4,2,1. If a carry
results when 6 is added, add the carry to the next
group.

Page 43
Chapter 1: Numbering system

Example A33: Add the following BCD codes?


a) ( 0101) + (0001)
b) (0011 0101) + (0010 0010)
c) (1001) + (1000)
d) (0110 0101) + (0010 0101)
e) (1000 0111) + (0101 0011)
Solution
a) 0101 5
0001 + 1
0110 Valid in BCD code. 6

b) 0011 0101  35
0010 0010 +  22 +
0101 0111 Valid in BCD code 57

c) (1001) + (1000)

1001 9
1000 + 8+
1 0001 Invalid because carry 17
0110 + Add 6
0001 0111
1 7

Page 44
Chapter 1: Numbering system

d) (0110 0101) + (0010 0101)


0110 0101  65
0010 0101  25 +
1000 1010 Right group invalid (>9) 90
0110 Add 6 to right group
1001 0000 Add carry to left group
9 0
e) (1000 0111) + (0101 0011)

1000 0111 87
0101 0011 + 53 +
1101 1010 Invalid both group (>9) 140

0110 0110 Add 6 to both groups


0001 0100 0000

1.6.4 Gray code (reflected code)

The gray code is unweighted code, there are no specific


weight assigned to the digit position. It is useful code
used in digital systems. In this code, the two successive
binary values differ in only one bit. The conversion
between decimal number and gray code is done by
converting the decimal number to binary number, and
then the binary number to gray code.

Page 45
Chapter 1: Numbering system

The table (A3) shows the gray code that corresponding


to decimal numbers and binary numbers.

Table A3
Decimal Binary Gray
0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100

1.6.5 Conversion gray code to binary number


To convert the decimal number to gray code, the
following steps are done.

1. The most significant bit (MSB), on the left, is the


MSB in binary number. In other word, they are same
value.
Page 46
Chapter 1: Numbering system

2. Add the first digit of the binary number to the second


digit in code of gray, the carry is ignored. In other
word, take XOR operation between them.

3. Generally working from the left to right digit, the n th


digit in the binary number is formed from summing
the (n+1)th digit in the binary number with the nth bit
in the gray code.

Example A35: Convert the gray code 11011 to binary


number?

Solution :

So, the binary number is 10010.

E01.[0

xample A36: Convert the gray code 110001 to binary


number?

Page 47
Chapter 1: Numbering system

Solution:

Gray code : 110001

Binary number: 1 0 0 0 0 1

1.6.6 Convert binary number to gray code

The conversion is down by the following steps:


1. Convert the decimal number to binary number.
2. The MSB digit in code of gray is the same as
corresponding digit in the addition of binary number.
3. Starting from left to right (MSB to LSB) , add each
adjacent pair of binary digits to get the next gray
digits, taking in the account carries are discard.
Example A37: Convert the following binary number
100110 to gray code?

Solution:

So the gray code is 110101.


Page 48
Chapter 1: Numbering system

Example A38: Convert the binary number 1010011 to


gray code?

Solution
Binary number: 1 0 1 0 0 1 1
Gray code :1 1 1 1 0 10

Example A39: Convert the numbers (44)10, (A.6)16


to gray codes:

Solution

First, convert the numbers to binary number.

(44)10 = (101100)2 ; (A6)16 = (10100110)2

Now, convert the binary number to gray code.

So, (44)10 = (111011)gray; (A6)16 = (11110101)gray


1.6.7 Error detection codes
An error detection code can be used to detect errors
during transmission. It is formed by adding additional

Page 49
Chapter 1: Numbering system

bit to the message information. This bit is called parity


bit. There are two types of parity:
1. Odd parity: Add bit to the message (0 or 1), so that
the total numbers of 1's became odd.
2. Even parity: Add bit to the message (0 or 1), so that
the total numbers of 1's became even.
Example A40:
The table A4 illustrates the odd and even parities.
Table A4: Odd parity and even parity
Message Odd Even
0000000 1 0
1011101 0 1
1100110 1 0
1111111 0 1

1.6.8 Alphanumeric code


Computers processes both numeric and alphabetic
information. Many coding systems have been
developed to represent alphanumeric information as a
sequences of 0’s and 1’s. The characters, which are

Page 50
Chapter 1: Numbering system

coded, are alphabets (26 letter), numerals (10 digits)


and special characters such as *,$, +,-, / … etc.
String of binary digits is used to code each character.
There are two standard codes have been used to ensure
uniformity in coding.
1. ASCII: It is American Standard Code for
Information Interchange. It has 128 characters and
each character represents by a 7 bits code. Actually,
ASCII can be considered an 8-bit code which MSB
for each character is 0.
2. EBCDIC: It is Extended Binary Coded Decimal
Interchange Code. For each character, 8-bit code are
used.
ASCII is represented in the form A6, A5, A4, A3, A2, A1,
A0. ASCII is used to code two types of information.
The first is the printable character such as digits,
alphabets, and special characters. The second is called
control characters, which are not printable, use to
represent the coded information to control the operation
of the digital computer.

Page 51

View publication stats

You might also like