0% found this document useful (0 votes)
59 views11 pages

Computer Arithmetic and Logic

This document introduces number systems used in computing including decimal, binary, and hexadecimal. It describes how each system represents numbers through place value and discusses techniques for converting between the systems. Specifically, it explains how binary uses bits and powers of two, hexadecimal uses digits 0-9 and A-F in groups of four bits, and how to convert a number from one system to another by grouping/dividing digits. The goal is for the reader to understand and work with all three number systems.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
59 views11 pages

Computer Arithmetic and Logic

This document introduces number systems used in computing including decimal, binary, and hexadecimal. It describes how each system represents numbers through place value and discusses techniques for converting between the systems. Specifically, it explains how binary uses bits and powers of two, hexadecimal uses digits 0-9 and A-F in groups of four bits, and how to convert a number from one system to another by grouping/dividing digits. The goal is for the reader to understand and work with all three number systems.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

UNIT 1: Number Systems

Contents
Introduction
Aim
Objective
Topics
Decimal Numbering System (Base 10)
Binary Numbering System (Base 2)
Binary-to-Decimal Conversion
Decimal-to-Binary Conversion
Hexadecimal Numbering System (Base 16)
Hexadecimal Conversions
Summary
Problems
References

1.1 Introduction
Computer systems operate using digital electronic circuits. Digital
circuitry uses binary input and output states which are represented
by 0 and 1. As humans we are accustomed to using a decimal
number system to perform arithmetic and other transactions. On the
other hand the computer uses the binary number system to perform
its functions. Therefore, it is important that for the human and the
computer to interface, there has to be a conversion between the two
systems. The hexadecimal number system is often used in computer
science because of its shorter code compared to the difficult to read
binary system. It is important for a computer programmer to be
familiar with this numbering system. In this unit decimal, binary and
hexadecimal number systems are introduced. In addition you will
learn techniques of how to convert between them.
1.2 Aim
This Unit aims to introduce you to the number systems used in
computer systems and how to convert between them.
6
1.3 Objectives
At the completion of this unit you should be able to

· Represent numbers in decimal, binary and hexadecimal


· Convert any number from the decimal, binary, and
hexadecimal systems to any of the other.

7
1.4 Topics

1.4.1 Decimal Numbering System (Base 10)


In the decimal system the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, are used for each
position of a number. Each position is weighted to a power of 10 depending on its
position. For the number 523 means

523 = (5 X 100) + (2 X 10) + 3

The decimal system is referred to as base, or radix, of 10. This means that each
digit in the number is multiplied by 10 raised to a power corresponding to that
digit’s position. Therefore the number 523 is

523 = (5 X 102) + (2 X 101) + 3 X 100

In a four-digit decimal number, the least significant position (rightmost)


has a weighting factor of 100; the most significant position (leftmost) has a
weighting factor of 103.

Figure 1

A number with both an integer and fractional part has digits raised to both
positive and negative powers of 10. Hence 523.24 is

523.24 = (5 X 102) + (2 X 101) + (3 X 100) + (2 X 10-1) + (4 X 10-2)

8
1.4.2 Binary Numbering System (Base 2)

In the binary number system the digits 0 and 1, are used for each position of a
number. Each position is weighted to a power of 2 depending on its position. For
the number 101 means

101 = (1 X 22) + (0 X 21) + (1 X 20) = 4 + 0 + 1 = 510 (or 5 in base 10)

The weighting factors for binary are shown in table 1

Figure 2: Binary weighting system

Example

A binary number with both an integer and fractional part has digits raised to both
9
positive and negative powers of 2. Hence 101.110 is

101.110 = (1 X 22) + (0 X 21) + (1 X 20) + (1 X 2-1) + (1 X 2-2) + (0 X 2-3)


101.110 = 4 + 0 + 1 + 0.5 + 0.25 + 0 = 5.65 10

Exercise

Convert the following binary numbers to decimal

1. 1101 1011 2. 1101.1011

1.4.2 Decimal to Binary Conversion


Two methods are used to convert decimal numbers to binary. These are
subtraction method and the successive division method.

10
1.4.2.1 Successive subtraction method.

The example below demonstrates this method


Example

1.4.2.1 Successive division method.

An easy method of converting decimal to binary number equivalents is to write


down the decimal number and to continually divide-by-2 (two) to give a result
and a remainder of either a “1” or a “0” until the final result equals zero. So for
example. Convert the decimal number 12210 into its binary number equivalent.

11
Example

The first remainder, 0, is the least significant bit (LSB) of the answer; the last
remainder, 1, is the most significant bit (MSB) of the answer. Therefore, the
answer is as follows:

12210 = 1111010

Exercise: Convert the decimal number 1243 10 to binary. Verify the answer by
converting back to decimal.

1.4.3 Hexadecimal Numbering System (Base 16)


The hexadecimal numbering system is a method of grouping bits to simplify
entering and reading the instructions or data present in digital computer systems.
Hexadecimal uses 4-bit groupings. In the hexadecimal number system the digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F are used for each position of a
number. Each position is weighted to a power of 16 depending on its position.
The digits A, B, C, D, E and F correspond to the decimal 10, 11, 12, 13, 14, and
15. The table below shows the relationship between decimal, binary and
hexadecimal.

12
Figure 3

1.4.3.1 Hexadecimal Conversion

For you to convert a binary number to hexadecimal number, group the binary
number in groups of 4 (starting from the least significant bit) and write down the
equivalent hex digit.

Exercise: Convert the following binary numbers to hexadecimal

Example 1: Convert the binary number


1011010110111111111010101 to hexadecimal.

Solution:
Step 1: Group the binary number in groups of 4
starting from the least significant. Left over digits are
padded with zeros. Hence

0001 0110 1011 0111 0111 1101 0101

Step 2: Write down the equivalent hex digit for each 4


digits

0001 0110 1011 0111 1111 1101 0101


1 6 B 7 F D 3

13
Exercise: Convert the following binary numbers to hexadecimal:
a. 1001110101111000
b. 1
01011100010

For you to convert a hexadecimal number to binary number, convert each


hex digit to its 4 bit binary equivalent.

Example: Convert the hex number 3FA6 16 to binary.

Solution:

3 F A 6
0011 1111 1010 0110

3FA616 = 0011111110100110 2

To convert a hexadecimal number to decimal convert each digit to its


decimal equivalent and multiply each number by a power of 16 depending
on its position.

Example: Convert the hex number 3FA616 to decimal.

Solution:

3 F A 6
3 15 10 6

3FA616 = (3 X 163) + (15 X 162) + (10 X 161) + (6 X 160)

3FA616 = (3 X 4096) + (15 X 256) + (10 X 16) + (6 X 1)

3FA616 = 12288 + 3840 + 160 + 6

3FA616 = 16294

14
To convert decimal numbers to hexadecimal use the repeated division
method as in the example below.

Example: Convert the decimal number 16294 to


hexadecimal.

Solution:

16294 ÷ 16 = 1018 remainder 6 = 6

1018 ÷ 16 = 63 remainder 10 = A

63 ÷ 16 = 3 remainder 15 = F

3 ÷ 16 = 0 remainder 3 = 3

1629410 = 3FA616

1.5 Summary
In this unit you have been introduced to the decimal, binary and
hexadecimal number systems that are used in digital computers. You
should be able to describe how they are represented. In addition you have
been shown the various techniques on how to convert between them. It is
important that you practice how to perform these techniques so that you
can quickly apply them as a programmer.

1.6 Problems

1. Convert the following binary numbers to their decimal equivalents:


a. 101100 b. 010011 c. 010100 d. 011100 e. 101110
2. Convert the following binary numbers to their decimal equivalents:
a. 10100.011 b. 110010.10011 c. 1010111010.1
3. Convert the following decimal numbers to their binary equivalents:
a. 63 b. 120 c. 113 d. 145 e. 20
4. Convert the following hexadecimal numbers to their decimal
equivalents:
a. 1C b. 9B c. C52 d. 8D2 e. ABCD
15
5. Convert the following decimal numbers to their hexadecimal
equivalents:
a. 16289 b. 9B c. C52 d. 8D2 e. ABCD
6. Convert the following hexadecimal numbers to their binary
equivalents:
a. 1C b. 9B c. C52 d. 8D2 e. ABCD
7. Convert the following binary numbers to their hexadecimal
equivalents:
a. 101100 b. 010011 c. 010100 d. 011100 e. 101110

1.7 References

http://code.tutsplus.com/articles/number-systems-an-introduction-to-
binary-hexadecimal-and-more--active-10848
http://www.byte-notes.com/number-system-computer

16

You might also like