Search

Binary Decimal and Hexadecimal numbers and conversions

Binary number system is a number system which is based on 2. What exactly is "based on 2"?? Well, you have only two characters ("0" and "1") to define and represent the entire numbers in binary number system.

Decimal number system is a number system which is based on 10. What exactly is "based on 10"?? Well, you have 10 characters ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9") to to define and represent the entire numbers in decimal number system.

Hexadecimal number system is a number system which is based on 16. What exactly is "based on 16"?? Well, you have 16 characters ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") to to define and represent the entire numbers in Hexadecimal number system.

How is this possible? Read below.

Binary Number System

Binary numbers allow us to represent any number using just two characters "0" and "1". Binary numbers are represented based on the powers of 2. To understand this concept more clearly, read the below table and memorize these numbers. This table is limited to 8 bit binary numbers and their conversions, because you will be dealing with 8 bit binary numbers more in your CCNA study (when you learn IPv4 addresses, subnetting, VLSM, Supernetting (Route Summarization) etc).

If you want to learn the conversion larger bit-size binary numbers, just add more powers of 2, like 512, 1024, 2048 etc.

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Decimal values 128 64 32 16 8 4 2 1

In the above table, right most bit (20) is known as the least significant bit and left most bit (27) is known as the most significant bit.

Whenever you are asked to convert from decimal number to binary number, or binary to decimal, remember the above table. As a network and network security engineer, you will need to do a lot of conversions from binary numbers to decimal numbers and back.

Example 1 - Convert 172 (in decimals) to its binary equivalant.

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 0 1 0 1 1 0 0
Decimal values 128 0 32 0 8 4 0 0

From the above table, if you make 27 (=128), 25 (=32), 23 (=8), and 22 (=4) bits "on" and remaining bits "off", you will get 172.

That is, 128+32+8+4 = 172

Therefore, the binary equivalant of 172 is 10101100.

Example 2 - Convert 192 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 1 0 0 0 0 0 0
Decimal values 128 64 0 0 0 0 0 0

From the above table, if you make 27 (=128), 26 (=64) bits "on" and remaining bits "off", you will get 192.

That is, 128+64=192.

Therefore, the binary equivalant of 192 is 11000000.

Example 3 - Convert 168 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 0 1 0 1 0 0 0
Decimal values 128 0 32 0 8 0 0 0

From the above table, if you make 27 (=128), 25 (=32) and 23 (=8) bits "on" and remaining bits "off", you will get 168.

That is, 128+32+8 = 168

Therefore, the binary equivalant of 168 is 10101000.

Example 4 - Convert 224 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 1 1 0 0 0 0 0
Decimal values 128 64 32 0 0 0 0 0

From the above table, if you make 27 (=128), 26 (=64) and 25 (=32) bits "on" and remaining bits "off", you will get 224.

That is, 128+64+32 = 224

Therefore, the binary equivalant of 224 is 11100000.

Example 5 - Convert 240 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 1 1 1 0 0 0 0
Decimal values 128 64 32 16 0 0 0 0

From the above table, if you make 27 (=128), 26 (=64), 25 (=32) and 24 (=16) bits "on" and remaining bits "off", you will get 240.

That is, 128+64+32+16 = 240

Therefore, the binary equivalant of 240 is 11110000.

Example 6 - Convert 248 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 1 1 1 1 0 0 0
Decimal values 128 64 32 16 8 0 0 0

From the above table, if you make 27 (=128), 26 (=64), 25 (=32), 24 (=16) and 23 (=8) bits "on" and remaining bits "off", you will get 248.

That is, 128+64+32+16+8 = 248

Therefore, the binary equivalant of 248 is 11111000.

Example 7 - Convert 252 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 1 1 1 1 1 0 0
Decimal values 128 64 32 16 8 4 0 0

From the above table, if you make 27 (=128), 26 (=64), 25 (=32), 24 (=16), 23 (=8) and 22 (=4) bits "on" and remaining bits "off", you will get 252.

That is, 128+64+32+16+8+4 = 252

Therefore, the binary equivalant of 252 is 11111100.

Example 8 - Convert 254 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 1 1 1 1 1 1 0
Decimal values 128 64 32 16 8 4 2 0

From the above table, if you make 27 (=128), 26 (=64), 25 (=32), 24 (=16), 23 (=8), 22 (=4) and 21 (=2) bits "on" and remaining bits "off", you will get 254.

That is, 128+64+32+16+8+4+2 = 254

Therefore, the binary equivalant of 254 is 11111110.

Example 9 - Convert 255 (in decimals) to its binary equivalant

Answer:

Powers of 2 (for 8 bits) 27 26 25 24 23 22 21 20
Binary Bits ("0" or "1") 1 1 1 1 1 1 1 1
Decimal values 128 64 32 16 8 4 2 1

From the above table, if you make 27 (=128), 26 (=64), 25 (=32), 24 (=16), 23 (=8), 22 (=4), 21 (=2) and 20 (=1) bits "on" (all the bits "on") you will get 255.

That is, 128+64+32+16+8+4+2+1 = 255

Therefore, the binary equivalant of 255 is 11111111. Now every bits in an eight bit binary number is "on". When you keep every bits in a binary number "on", you will get the maximum possible decimal value for that binary number.

The maximum possible decimal value for an eight bit binary number is 255.

Hexadecimal Number System

Hexadecimal number system is a number system which is based on 16. You have 16 characters ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") to to define and represent the entire numbers in Hexadecimal number system.

In Hexadecimal number system, 10 (in decimals) is represented by character "A", 11 (in decimals) is represented by character "B", 12 (in decimals) is represented by character "C", 13 (in decimals) is represented by character "D", 14 (in decimals) is represented by character "E" and 15 (in decimals) is represented by character "F".

Note: We use "0x" before the Hexadecimal number to indicate that it is a hexadecimal number, not a decimal number.

In decimal number system (which is based on 10 we use in our day-to-day life), the numbers are grouped based on 10. We count from 0 to 9, 10 to 19, 20 to 29 and so on.

In Hexadecimal number system, we count from 0x0 to 0xF (0 to 9 by using hexadecimal numbers 0x0 to 0x9 and 10 to 15 by using hexadecimal numbers "0xA" to "0xF"), 0x10 (16 in decimals) to 0x1F (31 in decimals), 0x20 (32 in decimals) to 0x2F (47 in decimals) and so on.

Refer the following table for a more clear view.

Decimal Binary Hexadecimal
0 0 0x0
1 1 0x1
2 10 0x2
3 11 0x3
4 100 0x4
5 101 0x5
6 110 0x6
7 111 0x7
8 1000 0x8
9 1001 0x9
10 1010 0xA
11 1011 0xB
12 1100 0xC
13 1101 0xD
14 1110 0xE
15 1111 0xF
16 10000 0x10
17 10001 0x11
18 10010 0x12
19 10011 0x13
20 10100 0x14
21 10101 0x15
22 10110 0x16
23 10111 0x17
24 11000 0x18
25 11001 0x19
26 11010 0x1A
27 11011 0x1B
28 11100 0x1C
29 11101 0x1D
30 11110 0x1E
31 11111 0x1F
32 100000 0x20
33 100001 0x21
34 100010 0x22
35 100011 0x23
36 100100 0x24
37 100101 0x25
38 100110 0x26
39 100111 0x27
40 101000 0x28
41 101001 0x29
42 101010 0x2A
43 101011 0x2B
44 101100 0x2C
45 101101 0x2D
46 101110 0x2E
47 101111 0x2F
48 110000 0x30
49 110001 0x31

As a network and network security engineer, you need to concentrate more on binary to hexadecimal conversion of 16-bit binary numbers, because IPv6 addresses are represented as blocks of 16-bit in hexadecimal numbers.

In a Binary to hexadecimal conversions, one hexadecimal digit resembles a group of four contiguous binary bits, called a nibble. The minimum possible decimal value for a 4-bit binary number is 0 and maximum is 15 (0xF).

Example 1 - Convert the following 16-bit binary number 0010001100000001 to hexadecimals.

Answer:

Nibbles 0010 0011 0000 0001
Hexadecimals 2 3 0 1

The hexadecimal equivalent of 16-bit binary number 0010001100000001 is 0x2301

Example 2 - Convert the following 16-bit binary number 0010100101000101 to hexadecimals.

Answer:

Nibbles 0010 1001 0100 0101
Hexadecimals 2 9 4 5

The hexadecimal equivalent of 16-bit binary number 0010100101000101 is 0x2945

Example 3 - Convert the following 16-bit binary number 0011111111100111 to hexadecimals.

Answer:

Nibbles 0011 1111 1110 0111
Hexadecimals 3 F E 7

The hexadecimal equivalent of 16-bit binary number 0011111111100111 is 0x3FE7

Example 4 - Convert the following 16-bit binary number 1111111010000000 to hexadecimals.

Answer:

Nibbles 1111 1110 1000 0000
Hexadecimals F E 8 0

The hexadecimal equivalent of 16-bit binary number 1111111010000000 is 0xFE80

 

Related Tutorials
How to use calculator for binary, decimal and hexadecimal number conversions
What is MAC address or Layer 2 address or physical address
Broadcast MAC Address - ff:ff:ff:ff:ff:ff
IPv4 multicast MAC Addresses
IPv4 Limited broadcast address
IPv4 Directed broadcast address
Class A networks and Class A IP addresses
Class B networks and Class B IP addresses
Class C networks and Class C IP addresses
Class D multicast IP addresses
IPv4 link-local multicast addresses
IPv4 Internetwork control block multicast addresses
IPv4 Source-Specific Multicast (SSM) address reservation
IPv4 GLOP multicast addresses
Administratively scoped multicast address block or Limited scope addresses
Class C Subnetting - Part 1
Class C Subnetting - Part 2
Class B Subnetting - Part 1
Class B Subnetting - Part 2
Class A Subnetting - Part 1
Class A Subnetting - Part 1
How to find out the Network Address and Broadcast Address of a subnetted IPv4 address