_________________________________________________________________

Number Systems Torn Apart By Ankit Fadia [email protected]

_________________________________________________________________

Number Systems play a very vital role in the knowledge of a computer geek. It is very useful to be accustomed with the various number systems as it not only helps in ,Reverse Engineering and Password Cracking, but also in various aspects of the encryption algorithms. Basically you cannot call yourself a Hacker without having adequate knowledge about the various number systems. The number systems that I would be discussing are the Decimal, Binary and Hexadecimal systems

Now Before we go on, let me tell you what a base or a radix is. The Base or the Radix of a number system is the number of unique or different digits that can possibly occur in that number system.

For example, The base or Radix of the Decimal System is 10. (0,1,2,3,4,5,6….9)

The Decimal Number System

This is the base 10 system as it can have 10 unique digits. The name itself comes from 'Deca' which means 10. The Decimal System has 10 different numerals. In this system, the digit on the left has more importance than the digit on the right. Now, let us see, how we can represent a number in the decimal system.

For Example,

632= 6*100 + 3*10 + 2*1 which actually is 6 multiplied by 10 raised to the power of 2 + 3 multiplied by 10 raised to the power of 1 + 2 multiplied by 10 raised to the power of 0. Remember from your math class that anything raised to the power of 0 is 1. Right?

Thus we can easily conclude that 10 is the base of the Decimal Number System. So now, we have a new definition of the base: It is the number which raised to the power of 0 assumes the lowest position value, raised to the power of 1 assigns the second last position and so on.

Binary Number System

The Binary Number System has only two unique numbers and hence is a Base 2 Number System. The computer can understand only a combination(or only them) of OFF and ON. Binary Number System contains only 0 and 1 amongst it digits. These digits 0 and 1 are called digits.

Now as the Binary Number System is a Base 2 Number System, according to the second definition of a Base(Radix) we can write the Binary Number 1101 in the form of:

1101 = 1 * 2 ^{3 }+ 1 * 2^{ 2 }+ 0 * 2^{1} + 1 * 2 ^{0}

This is the general format in which a Binary Number has to be written. Now if we continue the above process, we actually get the decimal form of the Binary Number.

1101 = 1 * 2 ^{3 }+ 1 * 2^{ 2 }+ 0 * 2^{1} + 1 * 2 ^{0}

= 8 + 4 + 0 +1

= 13

So 1101 is the Binary form of the Decimal Number 13. This method is the simplest method of converting Binary Numbers into Decimal form. The following is a Number System Conversion Table. Use it for conversion of smaller numbers.

Decimal Number System Binary Number System Hexadecimal Number System

0 0000 0

1 0001 1

2 0010 2

3 0011 3

4 0100 4

5 0101 5

6 0110 6

7 0111 7

8 1000 8

9 1001 9

10 1010 A

11 1011 B

12 1100 C

13 1101 D

14 1110 E

15 1111 F

Converting Decimal to Binary

To convert a number in the Decimal System to the Binary System, we keep on dividing the Decimal Number until it is reduced to 0. On dividing by 2, if there is a remainder of 1 then the corresponding

Binary Digit would be 1 else if the remainder is 0 then the Binary Digit will be 0.

To understand this concept better, lets study the following example,

Convert 15 from Decimal System to Binary System

15 / 2 = 7 Remainder =1 ----------------------------à 1

7 / 2 = 3 Remainder =1-----------------------------à 1

3 / 2 = 1 Remainder =1-----------------------------à 1

1 / 2 = 1 Remainder =1-----------------------------à 1

Therefore, the Binary version of 15 is 1111

Convert 252 from Decimal System to Binary System

252 /2 = 126 Remainder=0 --------------------------à 0

126 /2 = 63 Remainder=0 ---------------------------> 0

63 /2 = 31 Remainder=1 --------------------------à 1

31 /2 = 15 Remainder=1 --------------------------à 1

15 /2 = 7 Remainder=1 ---------------------------à 1

7 /2 = 3 Remainder=1 --------------------------à 1

3/2 = 1 Remainder=1 ---------------------------à 1

1/2 = 1 Remainder=1 --------------------------à 1

Hence, the Binary form of 252 in 111 111 00

You see it is that simple. The only thing to remember is that you take remainder from bottom to top. If this was not done, then the Binary version of 252 would have been 00 111 111 and not 111 111 00.

Practice Questions

Convert the following into Binary-:

- 47 (Answer is 10 11 11)
- 35 (Answer is 10 00 11)
- 22 (Answer is 10 11 0)

Converting Binary into Decimal

The decimal value of a binary number is equal to the sum of the decimal values of the binary digits. Understood? If not read the example, it will become more clear.

11 00 1 = 1 * 2^{4} + 1*2^{3} + 0*2^{2} + 1*2^{0 }

(Binary) = 16 + 8 + 1

= 25

Practice Questions

Convert the followingfrom Binary to Decimal-:

a) 110 110 (Answer is 54)

b) 111 111 00 (Answer is 252)

c) 11 00 11 01 (Answer is 205)

Conversion of fractional Decimals to Binaries is beyond the scope of this book and I decided not to include those subjects, as they are hardly of any use in Hacking.

The Hexadecimal System

The Hexadecimal Number System is a 16 Base Number System consisiting of 16 unique numbers ranging from 0, 1, 2, 3,4,5,6…9,A,B,C,D…F. They are 4 bit numbers which are also called nibbles (Assembly?)

Conversion from Hexadecimal to Binary to Decimal

The best way ti get the Decimal equivalent of a Hexadecimal is to convert it into first its Binary form and then convert the binary into Decimal. To convert the hexadecimal HD into binary, simply convert each digit into its Binary.

For Example,

9AF 9 = 1001 (In Binary)

A= 1010 (In Binary)

F= 1111 (In Binary)

C5E2 C= 1100(In Binary)

5=0101 (In Binary)

E=1110 (In Binary)

2=0010 (In Binary)

The above was the primitive or the lame method of conversion and always required the Number System Conversion Table. It is really inefficient and should almost always be avoided. There is yet another easier method. Consider the following example,

1AC = 1 * 16^{2} + 10 * 16^{1} + 12 * 16^{0}

= 428

Voila wasn't that kewl?

To convert Binary Numbers into Hexadecimal, follow the reverse of the above process.

ASCII

To get information in and out of a computer, we need numbers, characters and symbols. Earlier, all manufacturers had a different code, which was quite impractical and led to a lot of confusion. Hence eventually the entire industry settled on a standard for Input Output ( I\O) information Interchange which was known as the American Standard Code for Information Interchange or simply ASCII.

ASCII is a 8 bit code which can consist only of 0 and 1. The 8 bit ASCII code can be broken down into two smaller parts of 4 bits each. The plain text value of a 8 bit ASCII code is the value obtained at the intersection of the two 4 bit values in the ASCII chart. For Example,

0010 0011 0100 0101 0110 0111

0000 SP 0 @ P p

0001 ! 1 A Q a q

0010 " 2 B R b r

0011 # 3 C S c s

0100 $ 4 D T d t

0101 % 5 E U e u

0110 & 6 F V f v

0111 ' 7 G W g w

1000 ( 8 H X h x

1001 ) 9 I Y i y

1010 * : J Z j z

1011 + ; K k

1100 ' L l

1101 - = M m

1110 . N n

1111 / ? O o

For Example,

0100 0001 -----------> A

0110 0001 -----------> a

Well that all for this manual, till the next update goodbye. And Happy Number Conversions!!! ; )

Ankit Fadia

Get the Archive of Manuals [EVERYTHING YOU DREAMT OFF] written by Ankit Fadia

At his mailing list.

To get the manuals in your Inbox join his mailing list by sending an email to: