Lecturer : Najat Shyaa Jasim Subject : Computer Science
Number Systems
A number is a mathematical value used for counting and measuring
objects, and for performing arithmetic calculations. Numbers have
various categories like natural numbers, whole numbers, rational and
irrational numbers, and so on. Similarly, there are various types of
number systems that have different properties, like the binary number
system, the octal number system, the decimal number system, and the
hexadecimal number system.
What are Number Systems?
A number system is a system representing numbers. It is also called the
system of numeration and it defines a set of values to represent a quantity.
These numbers are used as digits and the most common ones are 0 and 1,
that are used to represent binary numbers. Digits from 0 to 9 are used to
represent other types of number systems.
Definition of Number Systems
A number system is defined as the representation of numbers by using
digits or other symbols in a consistent manner. The value of any digit in a
number can be determined by a digit, its position in the number, and the
base of the number system. The numbers are represented in a unique
manner and allow us to operate arithmetic operations like addition,
subtraction, and division.
Types of Number Systems
There are different types of number systems in which the four main types
are:
1-Binary Number System (Base - 2)
2- Octal Number System (Base - 8)
3- Decimal Number System (Base - 10)
4- Hexadecimal Number System(Base - 16)
We will study each of these systems one by one in detail.
24
Lecturer : Najat Shyaa Jasim Subject : Computer Science
Binary Number System
The binary number system uses only two digits: 0 and 1. The numbers in
this system have a base of 2. Digits 0 and 1 are called bits and 8 bits
together make a byte. The data in computers is stored in terms of bits and
bytes. The binary number system does not deal with other numbers such
as 2,3,4,5 and so on. For example: 100012, 1111012, 10101012 are some
examples of numbers in the binary number system.
Hence, in this system, the rightmost position is units (20) position, the
second position from the rights 2’s (21) position, and proceeding in this
way, we have 4’s (22) position, 8’s (23) position, 16’s (24) position, and so
on.
25
Lecturer : Najat Shyaa Jasim Subject : Computer Science
Octal Number System
The octal number system uses eight digits: 0,1,2,3,4,5,6 and 7 with the
base of 8. The advantage of this system is that it has lesser digits when
compared to several other systems, hence, there would be fewer
computational errors. Digits like 8 and 9 are not included in the octal
number system. Just as the binary, the octal number system is used in
minicomputers but with digits from 0 to 7. For example: 358, 238,
1418 are some examples of numbers in the octal number system.
Each position in an octal number represents a power of the base (8).
Decimal Number System
The decimal number system uses ten digits: 0,1,2,3,4,5,6,7,8 and 9 with
the base number as 10. The decimal number system is the system that we
generally use to represent numbers in real life. If any number is
represented without a base, it means that its base is 10. For example:
72310, 3210, 425710 are some examples of numbers in the decimal number
system.
26
Lecturer : Najat Shyaa Jasim Subject : Computer Science
Hexadecimal Number System
The hexadecimal number system uses sixteen digits/alphabets:
0,1,2,3,4,5,6,7,8,9 and A,B,C,D,E,F with the base number as 16. Here, A-
F of the hexadecimal system means the numbers 10-15 of the decimal
number system respectively. Here A is 10, B is 11, C is 12, D is 13, E is
14 and F is 15.
For example: 7B316, 6F16, 4B2A16 are some examples of numbers in the
hexadecimal number system.
27
Lecturer : Najat Shyaa Jasim Subject : Computer Science
CONVERSIONS
OTHER To DECIMAL :
The following steps are sued to convert a number in any other base to a
base 10 (decimal) number
Step 1 : Determine the column (positional) value of each digit (this
depends on the position of the digit and the base of the number system)
Step 2 : Multiply the obtained column values (in Step 1) by the digits in
the corresponding columns.
Step 3 : Sum up the products calculated in Step 2. The total is the
equivalent value in decimal.
1- BINARY TO DECIMAL
28
Lecturer : Najat Shyaa Jasim Subject : Computer Science
Example 3:
decimal equivalent of binary number 10101 (written as 10101 ) is :
(1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) + (1 x 20)
= 16 + 0 + 4 + 0 + 1
= 21
2- OCTAL TO DECIMAL
Example 2
Therefore, decimal equivalent of octal number 2057 (written as 2057) is:
(2 x 83) + (0 x 82) + (5 x 81) + (7 x 80) =
1024 + 0 + 40 + 7
= 1071
29
Lecturer : Najat Shyaa Jasim Subject : Computer Science
3-HEXADECIMAL TO DECIMAL
3840+64+12=391610
Example 2
Therefore, decimal equivalent of hexadecimal number 1 AF (written as 1AF16) is
(1 x 162) + (A x 161) + (F x 160)
= (1 x 256) + (10 x 16) + (15 x 1)
= 256 + 160 + 15= 431
Hence, 1AF16=43110
30
Lecturer : Najat Shyaa Jasim Subject : Computer Science
DECIMAL TO OTHER
Decimal Number System to Other Base
To convert Number system from Decimal Number System to Any Other
Base is quite easy; you have to follow just two steps:
A) Divide the Number (Decimal Number) by the base of target base
system (in which you want to convert the number: Binary (2), octal (8)
and Hexadecimal (16)).
B) Write the remainder from step 1 as a Least Signification Bit (LSB) to
Step last as a Most Significant Bit (MSB).
1-DECIMAL TO BINARY:
Example 1:convert (12345)10 to binary number
31
Lecturer : Najat Shyaa Jasim Subject : Computer Science
Example 2:convert (2 5)10 to binary number
2-DECIMAL TO OCTAL :
Example 1:convert (1234 5)10 to octal
32
Lecturer : Najat Shyaa Jasim Subject : Computer Science
Example 2:convert (266)10 to octal
3-DECIMAL TO HEXADECIMAL :
33