Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

Basics of Computers - Number System

The technique to represent and work with numbers is called number system. Decimal number
system is the most common number system. Other popular number systems include binary
number system, octal number system, hexadecimal number system, etc.

Decimal Number System


Decimal number system is a base 10 number system having 10 digits from 0 to 9. This means
that any numerical quantity can be represented using these 10 digits. Decimal number system
is also a positional value system. This means that the value of digits will depend on its position.
Let us take an example to understand this.
Say we have three numbers – 734, 971 and 207. The value of 7 in all three numbers is
different−

 In 734, value of 7 is 7 hundreds or 700 or 7 × 100 or 7 × 102


 In 971, value of 7 is 7 tens or 70 or 7 × 10 or 7 × 101
 In 207, value 0f 7 is 7 units or 7 or 7 × 1 or 7 × 100
The weightage of each position can be represented as follows −

In digital systems, instructions are given through electric signals; variation is done by varying
the voltage of the signal. Having 10 different voltages to implement decimal number system in
digital equipment is difficult. So, many number systems that are easier to implement digitally
have been developed. Let’s look at them in detail.

Binary Number System


The easiest way to vary instructions through electric signals is two-state system – on and off.
On is represented as 1 and off as 0, though 0 is not actually no signal but signal at a lower
voltage. The number system having just these two digits – 0 and 1 – is called binary number
system.
Each binary digit is also called a bit. Binary number system is also positional value system,
where each digit has a value expressed in powers of 2, as displayed here.

In any binary number, the rightmost digit is called least significant bit (LSB) and leftmost digit is
called most significant bit (MSB).
And decimal equivalent of this number is sum of product of each digit with its positional value.
110102 = 1×24 + 1×23 + 0×22 + 1×21 + 0×20
= 16 + 8 + 0 + 2 + 0
= 2610
Computer memory is measured in terms of how many bits it can store. Here is a chart for
memory capacity conversion.

 1 byte (B) = 8 bits


 1 Kilobytes (KB) = 1024 bytes
 1 Megabyte (MB) = 1024 KB
 1 Gigabyte (GB) = 1024 MB
 1 Terabyte (TB) = 1024 GB
 1 Exabyte (EB) = 1024 PB
 1 Zettabyte = 1024 EB
 1 Yottabyte (YB) = 1024 ZB

Octal Number System


Octal number system has eight digits – 0, 1, 2, 3, 4, 5, 6 and 7. Octal number system is also a
positional value system with where each digit has its value expressed in powers of 8, as shown
here −

Decimal equivalent of any octal number is sum of product of each digit with its positional value.
7268 = 7×82 + 2×81 + 6×80
= 448 + 16 + 6
= 47010

Hexadecimal Number System


Octal number system has 16 symbols – 0 to 9 and A to F where A is equal to 10, B is equal to
11 and so on till F. Hexadecimal number system is also a positional value system with where
each digit has its value expressed in powers of 16, as shown here −
As you know decimal, binary, octal and hexadecimal number systems are positional value
number systems. To convert binary, octal and hexadecimal to decimal number, we just need to
add the product of each digit with its positional value. Here we are going to learn other
conversion among these number systems.

Decimal to Binary
Decimal numbers can be converted to binary by repeated division of the number by 2 while
recording the remainder. Let’s take an example to see how this happens.

The remainders are to be read from bottom to top to obtain the binary equivalent.
4310 = 1010112

Decimal to Octal
Decimal numbers can be converted to octal by repeated division of the number by 8 while
recording the remainder. Let’s take an example to see how this happens.

Reading the remainders from bottom to top,


47310 = 7318

Decimal to Hexadecimal
Decimal numbers can be converted to octal by repeated division of the number by 16 while
recording the remainder. Let’s take an example to see how this happens.
Reading the remainders from bottom to top we get,
42310 = 1A716

Binary to Octal and Vice Versa


To convert a binary number to octal number, these steps are followed −


Starting from the least significant bit, make groups of three bits.


If there are one or two bits less in making the groups, 0s can be added after the most
significant bit


Convert each group into its equivalent octal number

Let’s take an example to understand this.

101100101012 = 26258
To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent
according to this table.

Octal Digit 0 1 2 3 4 5 6 7

Binary Equivalent 000 001 010 011 100 101 110 111
546738 = 1011001101110112

Binary to Hexadecimal
To convert a binary number to hexadecimal number, these steps are followed −


Starting from the least significant bit, make groups of four bits.


If there are one or two bits less in making the groups, 0s can be added after the most
significant bit.


Convert each group into its equivalent octal number.

Let’s take an example to understand this.

101101101012 = DB516
To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent.

Decimal equivalent of any hexadecimal number is sum of product of each digit with its
positional value.
27FB16 = 2×163 + 7×162 + 15×161 + 10×160
= 8192 + 1792 + 240 +10
= 1023410

Number System Relationship


The following table depicts the relationship between decimal, binary, octal and hexadecimal
number systems.
HEXADECIMAL DECIMAL OCTAL BINARY

0 0 0 0000

1 1 1 0001

2 2 2 0010

3 3 3 0011

4 4 4 0100

5 5 5 0101

6 6 6 0110

7 7 7 0111

8 8 10 1000

9 9 11 1001

A 10 12 1010

B 11 13 1011

C 12 14 1100

D 13 15 1101

E 14 16 1110

F 15 17 1111

ASCII
Besides numerical data, computer must be able to handle alphabets, punctuation marks,
mathematical operators, special symbols, etc. that form the complete character set of English
language. The complete set of characters or symbols are called alphanumeric codes. The
complete alphanumeric code typically includes −

 26 upper case letters


 26 lower case letters
 10 digits
 7 punctuation marks
 20 to 40 special characters
Now a computer understands only numeric values, whatever the number system used. So all
characters must have a numeric equivalent called the alphanumeric code. The most widely
used alphanumeric code is American Standard Code for Information Interchange (ASCII).
ASCII is a 7-bit code that has 128 (27) possible codes.
ISCII
ISCII stands for Indian Script Code for Information Interchange. IISCII was developed to
support Indian languages on computer. Language supported by IISCI include Devanagari,
Tamil, Bangla, Gujarati, Gurmukhi, Tamil, Telugu, etc. IISCI is mostly used by government
departments and before it could catch on, a new universal encoding standard
called Unicode was introduced.
Unicode
Unicode is an international coding system designed to be used with different language scripts.
Each character or symbol is assigned a unique numeric value, largely within the framework of
ASCII. Earlier, each script had its own encoding system, which could conflict with each other.
In contrast, this is what Unicode officially aims to do − Unicode provides a unique number for
every character, no matter what the platform, no matter what the program, no matter what the
language.

As you know decimal, binary, octal and hexadecimal number systems are positional value
number systems. To convert binary, octal and hexadecimal to decimal number, we just need to
add the product of each digit with its positional value. Here we are going to learn other
conversion among these number systems.

Decimal to Binary
Decimal numbers can be converted to binary by repeated division of the number by 2 while
recording the remainder. Let’s take an example to see how this happens.

The remainders are to be read from bottom to top to obtain the binary equivalent.
4310 = 1010112

Decimal to Octal
Decimal numbers can be converted to octal by repeated division of the number by 8 while
recording the remainder. Let’s take an example to see how this happens.
Reading the remainders from bottom to top,
47310 = 7318

Decimal to Hexadecimal
Decimal numbers can be converted to octal by repeated division of the number by 16 while
recording the remainder. Let’s take an example to see how this happens.

Reading the remainders from bottom to top we get,


42310 = 1A716

Binary to Octal and Vice Versa


To convert a binary number to octal number, these steps are followed −


Starting from the least significant bit, make groups of three bits.


If there are one or two bits less in making the groups, 0s can be added after the most
significant bit


Convert each group into its equivalent octal number

Let’s take an example to understand this.
101100101012 = 26258
To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent
according to this table.

Octal Digit 0 1 2 3 4 5 6 7

Binary Equivalent 000 001 010 011 100 101 110 111

546738 = 1011001101110112

Binary to Hexadecimal
To convert a binary number to hexadecimal number, these steps are followed −


Starting from the least significant bit, make groups of four bits.


If there are one or two bits less in making the groups, 0s can be added after the most
significant bit.


Convert each group into its equivalent octal number.

Let’s take an example to understand this.

101101101012 = DB516
To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent.

How to convert decimal to binary


Conversion steps:

1. Divide the number by 2.


2. Get the integer quotient for the next iteration.
3. Get the remainder for the binary digit.
4. Repeat the steps until the quotient is equal to 0.

Example #1

Convert 1310 to binary:


Divisio
Remainde
n Quotient Bit #
r
by 2

13/2 6 1 0

6/2 3 0 1

3/2 1 1 2

1/2 0 1 3
So 1310 = 11012
Example #2

Convert 17410 to binary:


Divisio
Remainde
n Quotient Bit #
r
by 2

174/2 87 0 0

87/2 43 1 1

43/2 21 1 2

21/2 10 1 3

10/2 5 0 4

5/2 2 1 5

2/2 1 0 6

1/2 0 1 7
So 17410 = 101011102
How to convert from decimal to octal
Conversion steps:

1. Divide the number by 8.


2. Get the integer quotient for the next iteration.
3. Get the remainder for the octal digit.
4. Repeat the steps until the quotient is equal to 0.

Example #1

Convert 756210 to octal:


Divisio
Quotient Remainder Remainder
n Digit #
(integer) (decimal) (octal)
by 8

7562/8 945 2 2 0

945/8 118 1 1 1

118/8 14 6 6 2

14/8 1 6 6 3

1/8 0 1 1 4
So 756210 = 166128
Example #2

Convert 3563110 to octal:


Division Remainder Remainder
Quotient Digit #
by 8 (decimal) (octal)

35631/
4453 7 7 0
8

4453/8 556 5 5 1

556/8 69 4 4 2

69/8 8 5 5 3

8/8 1 0 0 4

1/8 0 1 1 5
So 3563110 = 1054578
How to convert from decimal to hex
Conversion steps:

1. Divide the number by 16.


2. Get the integer quotient for the next iteration.
3. Get the remainder for the hex digit.
4. Repeat the steps until the quotient is equal to 0.

Example #1

Convert 756210 to hex:


Division Quotient Remainder Remainder
Digit #
by 16 (integer) (decimal) (hex)

7562/1
472 10 A 0
6

472/16 29 8 8 1

29/16 1 13 D 2

1/16 0 1 1 3
So 756210 = 1D8A16
Example #2

Convert 3563110 to hex:


Division Quotien Remainder Remainder
Digit #
by 16 t (decimal) (hex)

35631/16 2226 15 F 0

2226/16 139 2 2 1

139/16 8 11 B 2

8/16 0 8 8 3
So 3563110 = 8B2F16
How to convert binary to decimal
For binary number with n digits:
dn-1 ... d3 d2 d1 d0
The decimal number is equal to the sum of binary digits (d n) times their power
of 2 (2n):
decimal = d0×20 + d1×21 + d2×22 + ...
Example

Find the decimal value of 1110012:


binary
1 1 1 0 0 1
number:

power of 2: 25 24 23 22 21 20

1110012 = 1⋅25+1⋅24+1⋅23+0⋅22+0⋅21+1⋅20 = 5710


How to convert binary to octal
Convert every 3 binary digits (start from bit 0) to 1 octal digit, with this table:
Binary Octal
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
Example

Convert binary 11011002 to octal:


Convert every 3 binary bits (from bit0) to octal digit:
11011002 = 1 101 100 = 1 5 4 = 1548

Binary to Hex converter


窗体顶端
From
To
Enter binary number

= Convert × Reset Swap


Hex number

16
Decimal number

10
Digit grouping
Calculation

窗体底端
Hex to Binary converter ►
How to convert binary to hex
Convert every 4 binary digits (start from bit 0) to 1 hex digit, with this table:
Binary Hex
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Example

Convert binary 11011002 to hex:


Convert every 4 binary bits (from bit0) to hex digit:
11011002 = 110 1100 = 6 C = 6C16

Octal to Binary converter


窗体顶端
From
To

Enter octal number

= Convert × Reset Swap


Binary number

2
Decimal number

10
Digit grouping
Calculation

窗体底端
Binary to Octal converter ►
How to convert octal to binary
Convert every octal digit (start lowest digit) to 3 binary digits, with this table:
Octal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
Example

Convert octal 1548 to binary:


1548 = 1 5 4 = 1 101 100 = 11011002
How to convert from octal to decimal
A regular decimal number is the sum of the digits multiplied with 10 n.
Example #1

137 in base 10 is equal to each digit multiplied with its corresponding 10 n:


13710 = 1×102+3×101+7×100 = 100+30+7
Octal numbers are read the same way, but each digit counts 8 n instead of 10n.
Multiply each digit of the hex number with its corresponding 8 n.
Example #2

37 in base 8 is equal to each digit multiplied with its corresponding 8 n:


378 = 3×81+7×80 = 24+7 = 31
Example #3

7014 in base 8 is equal to each digit multiplied with its corresponding power
of 8:
70148 = 7×83+0×82+1×81+4×80= 3584+0+8+4 = 3596
How to convert octal to hex
Convert every octal digit to 3 binary digits, with this table:
Octal Binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
Then convert every 4 binary digits from bit0 to 1 hex digit, with this table:
Binary Hex
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Example

Convert octal 1548 to hex:


Convert every octal digit to 3 binary digits:
1548 = 001 101 100 = 0011011002
Then convert every 4 binary digits to 1 hex digit:
0011011002 = 0110 1100 = 6C16

How to convert hex to binary


Convert every hex digit (start lowest digit) to 4 binary digits, with this table:
Hex Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Example

Convert hex 6C16 to binary:


6C16 = 6 C = 110 1100 = 11011002
How to convert from hex to decimal
A regular decimal number is the sum of the digits multiplied with power of 10.
137 in base 10 is equal to each digit multiplied with its corresponding power
of 10:
13710 = 1×102+3×101+7×100 = 100+30+7
Hex numbers are read the same way, but each digit counts power of 16
instead of power of 10.
For hex number with n digits:
dn-1 ... d3 d2 d1 d0
Multiply each digit of the hex number with its corresponding power of 16 and
sum:
decimal = dn-1×16n-1 + ... + d3×163 + d2×162 +
d1×161+d0×160
Example #1

3B in base 16 is equal to each digit multiplied with its corresponding 16 n:


3B16 = 3×161+11×160 = 48+11 = 5910
Example #2

E7A9 in base 16 is equal to each digit multiplied with its corresponding 16 n:


E7A916 = 14×163+7×162+10×161+9×160 =
57344+1792+160+9 = 5930510
Example #3

0.8 in base 16:


0.816 = 0×160+8×16-1 = 0+0.5 = 0.510
How to convert hex to octal
Convert every hex digit (start lowest digit) to 4 binary digits, with this table:
Hex Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Then convert every 3 binary digits from bit0 to 1 octal digit, with this table:
Binary Octal
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
Example

Convert hex 6C16 to octal:


6C16 = 6 C = 110 1100 = 11011002
11011002 = 1 101 100 = 1 5 4 = 1548

You might also like