Number Systems

Introduction

The computer stores numbers, letters and other characters in a coded form due to its electronic characteristics. In digital system, all the data is represented by equivalent strings of symbols where each symbol is called a ‘bit’ (binary digit) which is either a ‘0’ or ‘1’.

Character Representation

Each character symbol is represented in computer language with its integral ASCII value. ASCII stands for ‘American Standard Code for Information Interchange’.

For example :–

‘A’-‘Z’ have ASCII Values ranging from 65 to 91
‘a’–‘z’ have ASCII value ranging from 97 to 122

Besides these 10 digits of decimal numbers and special characters, each one of these characters needs a unique binary pattern when stored inside the memory.

Number System

There are different number systems followed in general.The most commonly used number system is ‘Decimal number system’.

1) Decimal System : In this system, there are 10 digits : 0,1,2,3,4,5,6,7,8,9. The base of decimal number system is 10. When we have a sequence of decimal digits, for instance 1234, then each digit is multiplied by a weight, which is basically some power of 10 and that exponent value depends on position of the digit in the whole number.

Example :-

1234 = 1×103 + 2 x 102 + 3 x 101 + 4 x 100
12.34 = 1 x 101 + 2 x 100 + 3 x 10-1 + 4 x 10-2

2) Binary Number System : It has only two digits ‘0’ and ‘1’ so the base for binary number is 2.

Example – (101)2 in decimal would be

1 x 22 + 0 x 21 +1x 20 = (5)10

3) Octal Number Systems :

In octal number system, the base is 8, having eight symbols 0,1,2,3,4,5,6,7.For example, Octal number (25)8 in decimal will be represented as

2 x 81 + 5 x 80 = (21)10

4) Hexadecimal Number Systems :

The hexadecimal number system has a base 16 and digits 0 to 9 with

A = 10, B = 11, C = 12, D = 13, E = 14, F = 15

A hexadecimal number system ‘31’ can be expressed in expanded form with base 16 as

(31)16 = 3 x (16)1 + 1 x (16)0 = (64)10

Number System Conversions

Decimal to any other number system steps are as follows :

i) Divide the number by base and save reminder
ii) If quotient is ‘0’ , proceed to next step .
iii) If quotient is not ‘0’ , replace the number with quotient and repeat step (i).
iv) The conversion representation of the number is the remainder starting with the first remainder at the right.

Example –

Decimal to Binary Conversion

(32)10 = ( ? )2

Decimal to Binary

(32)10 = (100000 )2

Binary to Decimal Conversion

(10000)2 = (P)10 is accomplished by multiplying number by its weight, raise to the power its position.

(10000)2 = 1 x 25 + 0 x 24 + 0 x 23 + 0 x 22 + 0 x 21 + 0 x 20 = (32)10

(0.625)10 = (P)2

It is done by multiplying the fraction by the base of binary each time and take the integer part as the resultant output.

0.625 x 2 = 1.250 = 1
0.250 x 2 = 0.500 = 0
0.500 x 2 = 1.000 = 1
(0.625)10 = (0.101)2

Binary to Octal Conversion

Starting at the decimals point, divide the integer part and fractional part of the binary number into groups of three bits, each group representing an octal digit.

Example :–

Binary number, (111 00010.0001)2 in Octal form

011 100 010 .001
3 4 2 .1


Therefore, (111 00010.0001)2 = (342.1)8

Binary to Hexadecimal Conversion

Starting at the decimal point, divide the integer part and the fractional part of the binary number into groups of four bits. Each group represents a single hexadecimal digit.

(10011100.01)2 in ( ? )16

Binary to Hexadecimal Conversion

Reference

  • Reeta Sahoo, Computer science with C++ Pg – 269-278.