This post is also available in: हिन्दी (Hindi)

Computers interpret numbers differently from humans and thus require a different number system altogether. Whenever we type something on a device, those letters convert into certain numbers which only the computer can understand.

Since computers understand the language of switch ON (1) and switch OFF (0), the binary number system is the most commonly used number system in computers. The other number systems that are used in computers are the octal number system and the hexadecimal number system.

Let’s understand the following

- Octal Number System
- Hexadecimal Number System

## Commonly Used Number Systems

Simply put, a number system is a way to represent numbers. We are used to using the base-10 number system, which is also called decimal. Other common number systems include base-2 (binary), base-8 (octal), and base-16 (hexadecimal).

## What Does a Base or a Radix of a Number System Mean?

Radix is a term used to describe the number of digits utilized in a positional number system before “rolling over” to the next digit’s place. For example, in the base 10 number system, there is a total of 10 digits used (zero through nine), therefore, its radix is 10. In the base 2 number system, there are two numbers used (zero and one), so its radix is two. Other words that are synonymous with radix are base and root, in an arithmetic sense.

## Overview of Base 10 or Decimal Numbers

The decimal number system also known as the Hindu-Arabic or Arabic number system is the number system we use every day and uses digits from 0 – 9 i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, & 9. The base number of the decimal number system is 10 as the total number available in this number system is 10. If any number is represented without a base, it means that its base is 10. For example (564)10, (279)10 are commonly written as 564 and 279.

## 1. What is a Binary Number System?

“Bi” in Binary means “two”. A binary number system is the representation of a number in terms of 0 and 1 only. We can express any number in a decimal system in terms of a binary number system easily. Decimal numbers and binary numbers have different notations. Since a binary number system uses only two symbols or digits, the base or radix of the binary number system is 2. For example, 2 in decimal notation is represented as (2)_{10}. The binary number for 2 is represented as (10)_{2}. Hence, 10 is the binary number representation for the number 2.

## 1.1 How Do We Count using Binary?

To count in binary, you start with 0, then you go to 1. Then you add another digit as you do in decimal counting when you go from 9 to 10. You add another digit, so you have two digits now. So, in binary, you go from 1 to 10 since 1 is your last counting number. In decimal numbers, you go from 9 to 10, since 9 is the last number you can use when counting. Every time you reach the last counting number, you add another digit to your number.

So, counting in binary, you count like this:

0, 1, 10, 11, 100, 101, 110, 111, 1000. …

## 1. 2 Why are Binary Numbers used in Computers?

The advantage of the binary system is its simplicity. A computing device can be created out of anything that has a series of switches, each of which can alternate between an “on” position and an “off” position. These switches can be electronic, biological, or mechanical, as long as they can be moved on command from one position to the other. Most computers have electronic switches.

When a switch is “on” it represents the value of one, and when the switch is “off” it represents the value of zero. Digital devices perform mathematical operations by turning binary switches on and off. The faster the computer can turn the switches on and off, the faster it can perform its calculations.

## 1.3 Conversion – Binary to Decimal and Vice-Versa

Since the base or radix of a binary number system is 2, hence it plays an important role in the conversion of decimal numbers to binary numbers and vice-versa.

To do the conversion process we need to understand the math behind it. The foremost thing here is to be aware of the powers of 2.

2^{0} = 1; 2^{1} = 2; 2^{2} = 4; 2^{3} = 8; 2^{4} = 16; 2^{5} = 32; 2^{6} = 64, 2^{7} = 128, 2^{8} = 256, ….

If you memorize some of the first powers of 2, you will be able to do these conversions quickly.

### 1.3.1 Decimal to Binary Conversion

Let’s look at the decimal-to-binary conversion. To convert a decimal number to its binary equivalent, it is divided by 2 and its remainder is noted down. The process is repeated till the number reduces to 0. A binary number is formed by collecting all the remains from bottom to top.

Consider an example of decimal number 146

So, (146)_{10} = (10010010)_{2}

Consider one more example of the decimal number 98

So, (98)_{10} = (01100010)_{2}

Now, let’s see a quicker way of converting a binary number to a decimal number.

The first step is to write the power of 2 tables, starting from right to leave as shown

128 64 32 16 8 4 2 1

These are 8 numbers that we can use to convert to 8-bit binary numbers.

Let’s see how to convert a decimal number 146 to its binary equivalent.

Now, we split the given number in terms of numbers in the table

146 goes with 128, 1 time.

146 = 128 × 1 + 18

Now, move on to 18

18 = 16 × 1 + 2

So, we get 146 = 128 + 16 + 2

And the table becomes

128 64 32 16 8 4 2 1

1 0 0 1 0 0 1 0

148 = (10010010)_{2}

Let’s take one more example, say 98

98 = 64 × 1 + 34

34 = 32 × 1 + 2

Which gives 98 = 64 + 32 + 2 and table becomes

128 64 32 16 8 4 2 1

0 1 1 0 0 0 1 0

98 = (01100010)_{2}

### 1.3.2 Binary to Decimal Conversion

To convert a binary number to its equivalent, it is expanded in the powers of 2 from right to left, powers starting from 0 and increasing by 1.

Let’s consider the binary number obtained in the example considered above – (01100010)_{2}

01100010 = 0 × 2^{0} + 1 × 2^{1} + 0 × 2^{2} + 0 × 2^{3} + 0 × 2^{4} + 1 × 2^{5} + 1 × 2^{6} + 0 × 2^{7}

= 0 × 1 + 1 × 2 + 0 × 4 + 0 × 8 + 0 × 16 + 1 × 32 + 1 × 64 + 0 × 128

= 0 + 2 + 0 + 0 + 0 + 32 + 64 + 0

= 98

That gives (01100010)_{2} = (98)_{10}

Similarly, we can convert 10010010 to decimal

10010010 = 0 × 2^{0} + 1 × 2^{1} + 0 × 2^{2} + 0 × 2^{3} + 1 × 2^{4} + 0 × 2^{5} + 0 × 2^{6} + 1 × 2^{7}

= 0 × 1 + 1 × 2 + 0 × 4 + 0 × 8 + 1 × 16 + 0 × 32 + 0 × 64 + 1 × 128

= 0 + 2 + 0 + 0 + 16 + 0 + 0 + 128

= 146

So, (10010010)_{2} = (146)_{10}

Now, let’s see a quicker way of converting a binary number to a decimal number. Again recall the same table

Write the power of 2 tables, starting from right to left as shown

128 64 32 16 8 4 2 1

Let’s see how (11000101)_{2} is converted to the decimal equivalent. Write individual digits of a binary number (bits) under the numbers of a table

128 64 32 16 8 4 2 1

1 1 0 0 0 1 0 1

Now, just add the numbers corresponding to 1 in binary

128 + 64 + 4 + 1 = 197

So, (11000101)_{2} = (197)_{10}

Let’s consider one more example – (10011101)_{2}

Again write the numbers in a table as

128 64 32 16 8 4 2 1

1 0 0 1 1 1 0 1

Now, add the numbers corresponding to 1 in binary

128 + 16 + 8 + 4 + 1 = 157

So, (10011101)_{2}^{ } = (157)_{10}

## 1.4 Binary Arithmetic

Binary arithmetic is used in digital systems mainly because the numbers (decimal and floating-point numbers) are stored in binary format in most computer systems. All arithmetic operations such as addition, subtraction, multiplication, and division are done in the binary representation of numbers. Therefore, It is necessary to understand at least two basic binary arithmetic operations – Addition and Subtraction.

### 1.4. 1 Binary Arithmetic – Addition

Before working out some problems, we’re going to show you some rules that we’ll follow to make it really very easy.

The first important part of the rule is to follow the table.

0 + 0 = 0; 0 + 1 = 1; 1 + 0 = 1; 1 + 1 = 10 (Read as one, zero, and not ten) Here 1 is carried forward.

Other simple rules to follow:

- Always add two digits at a time to keep the process simple
- Work one column at a time

Now, let’s take an example and use these rules to add binary numbers.

(1010)_{2} which is 10 and (101)_{2} which is 5

Just wait, before adding any two numbers, make sure they have the same number of digits. So, we will write (101)_{2} = (0101)_{2}

*Adding any number of zeroes to the left of a number doesn’t change its value.*

First step: Write the numbers in the column

Next step: Recall the table and follow the rules of the table

(1111)_{2} = 15 and also 10 + 5 = 15

Now, let’s add three binary numbers

(1101)_{2} = 13; (110)_{2} = 6 and (1011)_{2} = 11

(110)_{2} will be written as (0110)_{2}

Now, all three numbers have the same number of digits.

First let’s consider (1101)_{2} and (110)_{2} (You can take any two numbers first, it will not affect the final result. Remember the associative property of addition. In this case, also, it works fine.

Now, follow the next steps

(1101)_{2} + (110)_{2} = (10011)_{2} = 30 and also 13 + 6 + 11 = 30

Now add the remaining number to the result obtained just now.

So, (1101)_{2} + (110)_{2} + (1011)_{2} = (11110)_{2} = 30 in decimal

### 1.4. 2 Binary Arithmetic – Subtraction

Before working out some problems, we’re going to show you some rules that we’ll follow to make it really very easy.

The first important part of the rule is to follow the table.

0 – 0 = 0; 1 – 1 = 0; 1 – 0 = 1; 0 – 1 = 1 (Here 1 is borrowed)

Other simple rules to follow:

- Always add two digits at a time to keep the process simple
- Work one column at a time

Now, let’s take an example and use these rules to subtract binary numbers.

(1101)_{2} which is 13 and (100)_{2} which is 4

Write (100)_{2} as (0100)_{2} to make the number of digits the same.

First step: Write the numbers in the column

Next step: Recall the table and follow the rules of the table

So, (1101)_{2} – (100)_{2} = (1001)_{2} = 9 and also 13 – 4 = 9

## 1.5 Conversion of Fractional Numbers to Binary

Fractional numbers are numbers that contain a whole part and a fractional part. The fractional part is either written in the form of a numerator and denominator or is separated from the whole part by a decimal point (.).

For example, 137.45 is a fractional number that can also be written as (137 9/20), where 137 is a whole (integral) part and 9/20 is a fractional part.

Now, to do the conversion process we need to understand the math behind it. The foremost thing here is to be aware of the positive powers of 2

2^{0} = 1; 2^{1} = 2; 2^{2} = 4; 2^{3} = 8; 2^{4} = 16; 2^{5} = 32; 2^{6} = 64, 2^{7} = 128, 2^{8} = 256, ….

Similarly, the negative powers of 22^{-1} = 1/2; 2^{-2} = 1/4; 2^{-3} = 1/8; 2^{-4} = 1/16; 2^{-5} = 1/32; 2^{-6} = 1/64, 2^{-7} = 1/128, 2^{-8} = 1/256, ….

### 1.5. 1 Fractional Decimal to Binary Numbers

To convert a fractional decimal number to binary, a number is multiplied by 2, its integral part is noted down and the fractional part is again multiplied by 2. The process is repeated till the fractional part becomes 0. After that, all the integral parts are collected from bottom to top.

To make it clear, let’s consider the example of 0.125

0.125 × 2 = 0.250 (Take out the **integral part i.e., 0,** and multiply the remaining part)

0.25 × 2 = 0.50 (Take out the **integral part i.e., 0,** and multiply the remaining part)

0.50 × 2 = 1.0 (Take out the **integral part i.e., 1,** and stop as the fractional part becomes 0)

So, (0.125)_{10} = (0.100)_{2} (Collecting integral parts from bottom to top)

Now, let’s convert the fractional part, i.e., 0.234

0.234 × 2 = 0.468 (Take out the **integral part i.e., 0,** and multiply the remaining part)

0.468 × 2 = 0.936 (Take out the **integral part i.e., 0,** and multiply the remaining part)

0.936 × 2 = 1.872 (Take out the **integral part i.e., 1,** and multiply the remaining part)

0.872 × 2 = 1.744 (Take out the **integral part i.e., 1,** and multiply the remaining part)

0.744 × 2 = 1.488 (Take out the **integral part i.e., 1,** and multiply the remaining part)

0.488 × 2 = 0.976 (Take out the **integral part i.e., 0,** and multiply the remaining part)

0.976 × 2 = 1.952 (Take out the **integral part i.e., 1,** and multiply the remaining part)

You can see that we are not getting 0 as a fractional value. The reason is – it’s a non-terminating decimal number. In such cases, stop after a few steps. It will give you an approximate value. More steps, more precise or exact value.

So, (0.234)_{10} = (0.0011101)_{2}

If we have a mixed number, i.e., a number having both integral and fractional parts, then the integral part and fractional part are converted separately and finally, the two results are written together.

For example, converting 98.234 to its binary equivalent. Here the integral part is 98 and the fractional part is 0.234.

(98)_{10} = (01100010)_{2}

And (0.234)_{10} = (0.0011101)_{2}

Hence, (98.234)_{10} = (01100010.0011101)_{2}

### 1.5.2 Fractional Binary to Decimal Conversion

To convert a fractional binary to its decimal equivalent, the process is the same as used to convert a binary to its decimal equivalent, i.e., expand in the powers of 2.

But, in this case, the expansion starts from left to right and the powers are negative numbers starting from -1.

For example, let’s convert 0.100 to its decimal equivalent.

0.100 = 1 × 2^{-1} + 0 × 2^{-2} + 0 × 2^{-3}

= 1 × ½ + 0 × ¼ + 0 × ⅛

= ½ = 0.5

So, (0.100)_{2} = (0.5)_{10}

Let’s consider one more example of (0.0011101)_{2}

0.0011101 = 0 × 2^{-1} + 0 × 2^{-2} + 1 × 2^{-3} + 1 × 2^{-4} + 1 × 2^{-5} + 0 × 2^{-6} + 1 × 2^{-7}

= 0 × ½ + 0 × ¼ + 1 × ⅛ + 1 × 1/16 + 1 × 1/32 + 0 × 1/64 + 1 × 1/128

= 0 + 0 + ⅛ + 1/16 + 1/32 + 0 + 1/128

= 29/128 = 0.2265625

So, (0.0011101)_{2} = (0.2265625)_{10}

Let’s consider one more example – (01001110.0011)_{2}

Write the numbers in a table as

128 64 32 16 8 4 2 1 ½ ¼ ⅛ 1/16

0 1 0 0 1 1 1 0 0 0 1 1

Now, add the numbers corresponding to 1 in binary

64 + 8 + 4 + 2 + ⅛ + 1/16 = 78 + 0.1875

So, (10011101)_{2}^{ } = (78.1875)_{10}

## 1.6 How Negative Numbers are Represented in Binary?

Negative numbers can be distinguishable with the help of an extra bit or flag called a sign bit or sign flag in the Binary number representation system for signed numbers. It is not possible to add minus or plus symbols in front of a binary number because a binary number can have only two symbols either 0 or 1 for each position or bit.

That’s why we use this extra bit called sign bit or sign flag. The value of the sign bit is 1 for negative binary numbers and 0 for positive numbers.

When an integer binary number is positive, the sign is represented by 0 and the magnitude by a positive binary number.

A binary number can be converted to its corresponding negative number by using its 2’s complement. 2’s complement of a binary number is obtained by adding 1 to its 1’s complement.

### 1.6.1 What is 1’s Complement of a Binary Number?

1’s complement of a binary number is obtained by replacing 0s in a number with 1s and 1s with 0s.

For example, 1’s complement of 10110010 is 01001101

Similarly, 1’s complement of 01001110 is 10110001

### 1.6.2 What is 2’s Complement of a Binary Number?

2’s complement of a binary number is obtained by adding 1 to its 1’s complement.

(2’s complement of a binary number) = (1’s complement of a binary number) + 1

For example, we want to find 2’s complement of 10110010

2’s complement of 10110010 = 1’s complement of 10110010 + 1

= 10110001 + 1 = 10110011

Similarly, 2’s complement of 01001110 = (1’s complement of 01001110) + 1

### 1.6. 3 Finding the Negative of a Binary Number Using 2’s Complement Method

Let’s see how the number -236 can be represented in binary.

236 in binary using 8-bit code is (11101100)_{2}

1’s complement of 11101100 is 00010011

2’s complement of 11101100 is 00010011 + 1 = 00010100

Therefore, -236 = 100010100

Note that there are 9 bits in the negative number. The leftmost extra 1 indicates a negative number.

## 2. What is an Octal Number System?

Octa means “eight”. An octal number system is the representation of a number in terms of digits from 0 to 7 (0, 1, 2, 3, 4, 5, 6 & 7). We can express any number in a decimal system in terms of an octal number system easily. Since a binary number system uses eight symbols or digits, the base or radix of the octal number system is 8. For example, 12 in decimal notation is represented as (12)_{10}. The octal number for 12 is represented as (14)_{8}. Hence, 14 is the octal number representation for the number 12.

## 2.1 How Do We Count Using Octal?

To count in octal, you start with 0, then you go to 1, and then 2, 3, and so on up to 7. After 7, as you do in decimal counting when you go from 9 to 10, in octal after 7, the next number is 10. You add another digit, so you have two digits now. Every time you reach the last counting number, you add another digit to your number.

So, counting in octal, you count like this:

0 1 2 3 4 5 6 7

10 11 12 13 14 15 16 1720 21 22 23 24 25 26 27, and so on.

## 2.2 Why are Octal Numbers used in Computers?

The octal numbers are not as common as they used to be. However, Octal is used when the number of bits in one word is a multiple of 3. It is also used as a shorthand for representing file permissions on UNIX systems and the representation of UTF8 numbers, etc.

The main advantage of using octal numbers is that it uses fewer digits than the decimal and Hexadecimal number system. So, it has fewer computations and fewer computational errors. It uses only 3 bits to represent any digit in binary and is easy to convert from octal to binary and vice-versa. It is easier to handle input and output in the octal form.

The major disadvantage of the octal number system is that computers do not understand the octal number system directly, so we need an octal-to-binary converter.

## 2.3 Conversion – Octal to Decimal & Vice-Versa

Since the base or radix of a binary number system is 8, hence it plays an important role in the conversion of decimal numbers to octal numbers and vice-versa.

To do the conversion process we need to understand the math behind it. The foremost thing here is to be aware of the powers of 8.

8^{0} = 1; 8^{1} = 8; 8^{2} = 64; 8^{3} = 512; 8^{4} = 4096, ….

If you memorize some of the first powers of 8, you will be able to do these conversions quickly.

### 2.3.1 Decimal to Octal Conversion

Let’s look at the decimal to octal conversion. To convert a decimal number to its octal equivalent, it is divided by 8 and its remainder is noted down. The process is repeated till the number reduces to 0. An octal number is formed by collecting all the remains from bottom to top.

Consider an example of decimal number 1468

So, (1468)_{10} = (02674)_{8}

Consider one more example of the decimal number 2985

So, (98)_{10} = (05651)_{8}

### 2.3.2 Octal to Decimal Conversion

To convert an octal number to its equivalent, it is expanded in the powers of 8 from right to left, powers starting from 0 and increasing by 1.

Let’s consider the octal number obtained in the example considered above – (02674)_{8}

02674 = 4 × 8^{0} + 7 × 8^{1} + 6 × 8^{2} + 2 × 8^{3} + 0 × 8^{4}

= 4 × 1 + 7 × 8 + 6 × 64 + 2 × 512 + 0 × 4096

= 4 + 56 + 384 + 1024 + 0

= 1468

Finally, (02674)_{8} = (1468)_{10}

## 3. What is a Hexadecimal Number System?

Hexa means “six” and decimal means “10”. The hexadecimal number system is the representation of a number in terms of 10 digits of the decimal number system and 6 English letters viz. A, B, C, D, E, and F, where these letters are used to represent: A – 10, B – 11, C – 12, D – 13, E – 14, and F – 15. Since a hexadecimal number system uses sixteen symbols or digits, the base or radix of the hexadecimal number system is 16. For example, 165 in decimal notation is represented as (165)_{10}. The hexadecimal number for 165 is represented as (A5)_{16}. Hence, A5 is the hexadecimal number representation for the number 165.

## 3.1 How Do We Count Using Hexadecimal?

To count in hexadecimal, you start with 0, then you go to 1, and then 2, 3, and so on up to 9. After 9, comes A, then B, and so on up to F. As you do in decimal counting when you go from 9 to 10, in hexadecimal after F, the next number is 10. You add another digit, so you have two digits now. Every time you reach the last counting number, you add another digit to your number.

So, counting in hexadecimal, you count like this:

0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20

## 3.2 Where are Hexadecimal Numbers used in Computers?

The hexadecimal numbering system is often used by programmers to simplify the binary numbering system. Since 16 is equivalent to 24, there is a linear relationship between the numbers 2 and 16.

This means that one hexadecimal digit is equivalent to four binary digits. Computers use binary numbering systems while humans use hexadecimal numbering systems to shorten binary and make it easier to understand.

Hexadecimal is used in the following:

- To define locations in memory. Hexadecimal can characterize every byte as two hexadecimal digits only compared to eight digits when using binary.
- To define colours on web pages. Each primary colour – red, green, and blue is characterized by two hexadecimal digits. The format being used is #RRGGBB. RR stands for red, GG stands for green and BB stands for blue.
- To represent Media Access Control (MAC) addresses. MAC addresses consist of 12-digit hexadecimal numbers. The format being used is either MM:MM:MM:SS:SS:SS or MMMM-MMSS-SSSS. The first 6 digits of the MAC address represent the ID of the adapter manufacturer while the last 6 digits represent the serial number of the adapter.
- To display error messages. Hexadecimal are used to define the memory location of the error. This is useful for programmers in finding and fixing errors.

**Advantages of the Hexadecimal System**

Here are some advantages of using the hexadecimal system:

- It is very concise and using a base of 16 means that the number of digits used to signify a given number is usually less than in binary or decimal. It allows you to store more information using less space.
- It is fast and simple to convert between hexadecimal numbers and binary. Hexadecimal can be used to write large binary numbers in just a few digits.
- It makes life easier as it allows the grouping of binary numbers which makes it easier to read, write and understand. It is more human-friendly, as humans are used to grouping together numbers and things for easier understanding. Also, writing in fewer digits lowers the possibility of an error occurring.

## 3.3 Conversion – Hexadecimal to Decimal & Vice-Versa

Since the base or radix of a hexadecimal number system is 16, hence it plays an important role in the conversion of decimal numbers to hexadecimal numbers and vice-versa.

To do the conversion process we need to understand the math behind it. The foremost thing here is to be aware of the powers of 16.

16^{0} = 1; 16^{1} = 16; 16^{2} = 256; 16^{3} = 4096; 16^{4} = 65536, ….

If you memorize some of the first powers of 16, you will be able to do these conversions quickly.

### 3.3.1 Decimal to Hexadecimal Conversion

Let’s look at the decimal to hexadecimal conversion. To convert a decimal number to its hexadecimal equivalent, it is divided by 16 and its remainder is noted down. If the remainder is 10, it is replaced by A. Similarly the remainder of 11, 12, 13, 14, or 15 is replaced by B, C, D, E, or F. The process is repeated till the number reduces to 0. A hexadecimal number is formed by collecting all the remains from bottom to top.

Consider an example of decimal number 4285

So, (4285)_{10} = (10BD)_{16}

Consider one more example of decimal number 12647

So, (12647)_{10} = (03167)_{16}

### 3.3.2 Hexadecimal to Decimal Conversion

To convert a hexadecimal number to its equivalent, it is expanded in the powers of 16 from right to left, powers starting from 0 and increasing by 1.

Let’s consider the hexadecimal number (341)_{16}

341 = 1 × 16^{0} + 4 × 16^{1} + 3 × 16^{2}

= 1 × 1 + 4 × 16 + 3 × 256

= 833

Finally, (341)_{16} = (833)_{10}

Let’s consider one more example, A5D9

A5D9 = 9 × 16^{0} + D × 16^{1} + 5 × 16^{2} + A × 16^{3}

= 9 × 1 + D × 16 + 5 × 256 + A × 4096

= 9 × 1 + 13 × 16 + 5 × 256 + 10 × 4096

= 42457

So, (A5D9)_{16} = (42457)_{10}

## 4. Other Conversions

Let’s consider the other between these number systems.

### 4.1 Binary to Octal and Vice-Versa

The following table is taken as a reference to convert a binary number to its octal equivalent:

#### 4.1.1 Binary to Octal

To convert a binary number to its octal equivalent, we group the digits in a group of 3 (since, 2^{3} = 8) and write their equivalent octal codes.

For example, we want to convert (11001111010)_{2} to its octal equivalent.

The first step is to make a group of three starting from the right.

(011)(001)(111)(010) (In case of any shortage, just add the required number of 0s to the left).

Now, for each group, write its octal equivalent (Taking the above table as a reference).

(011)(001)(111)(010) = 3172So, (11001111010)_{2} = (3172)_{8}

#### 4.1.2 Octal to Binary

In order to convert an octal number to its binary equivalent, again take the above table as a reference and replace each octal digit with its equivalent binary code.

Consider an octal number 6042

(6)_{8} = (110)_{2}

(0)_{8} = (000)_{2}

(4)_{8} = (100)_{2}

(2)_{8} = (010)_{2}

So, (6042)_{8} = (110000100010)_{2}

### 4.2 Binary to Hexadecimal and Vice-Versa

The following table is taken as a reference to convert a binary number to its hexadecimal equivalent:

#### 4.2.1 Binary to Hexadecimal

To convert a binary number to its hexadecimal equivalent, we group the digits in a group of 4 (since 2^{4} = 16) and write their equivalent hexadecimal codes.

For example, we want to convert (10100011111001)_{2} to its hexadecimal equivalent.

The first step is to make a group of four starting from the right.

(0010)(1000)(1111)(1001) (In case of any shortage, just add the required number of 0s to the left).

Now, for each group, write its hexadecimal equivalent (Taking the above table as a reference).

(0010)(1000)(1111)(1001) = 28F9

So, (10100011111001)_{2} = (28F9)_{16}

#### 4.2.2 Hexadecimal to Binary

In order to convert a hexadecimal number to its binary equivalent, again take the above table as a reference and replace each hexadecimal digit with its equivalent binary code.

Consider an hexadecimal number 1A0D

(1)_{16} = (0001)_{2}

(A)_{16} = (1010)_{2}

(0)_{16} = (0000)_{2}

(D)_{16} = (1101)_{2}

So, (1A0D)_{8} = (000110100001101)_{2} = (110100001101)_{2}

## Practice Problems

- Convert the following decimal numbers to binary numbers
- 67
- 197
- 163
- 285
- 534

- Convert the following binary numbers to decimal numbers
- 11000011
- 10001110
- 1111000001
- 1000011001
- 11100011

- Convert the following decimal numbers to octal numbers
- 564
- 839
- 1239
- 3412
- 4329

- Convert the following octal numbers to decimal numbers
- 1111
- 7621
- 54
- 7520
- 1000

- Convert the following decimal numbers to hexadecimal numbers
- 76
- 187
- 294
- 675
- 1876

- Convert the following hexadecimal numbers to decimal numbers
- FACE
- 1002
- AA00
- 12BC
- CA29

- Convert the following binary numbers to octal numbers
- 1111000011100
- 1100100001

- Convert the following binary numbers to hexadecimal numbers
- 111100000111100
- 1100000000111001

## FAQs

### What is a number system and its types in computers?

The way of representing numbers is called a number system. The four common types of Number systems are Decimal Number System, Binary Number System, Octal Number System, and Hexadecimal Number System.

### Why do computers use number systems?

When we type some letters or words, the computer translates them in numbers as computers can understand only numbers. A computer can understand the positional number system where there are only a few symbols called digits and these symbols represent different values depending on the position they occupy in the number.

### Why computer uses 0 and 1?

Since computers understand the language of switch ON (1) and switch OFF (0), the binary number system is the most commonly used number system in computers.

## Conclusion

The number system is an essential part of computer technology enabling computers to perform all functions in just a few seconds. The three commonly used number systems viz., binary, octal, and hexadecimal play important roles in different applications and areas of computer and digital technology.

## Recommended Reading

- How to Avoid Silly Mistakes in Maths
- Online Maths Competition in 2022
- Greatest Discoveries in Mathematics