A number system, or numeral system, is a method for representing numbers using symbols, crucial in mathematics and programming for data representation. It involves using digits to construct numbers, where each digit’s value is determined by its position and the base value of the system. While computers primarily use the binary system of 0s and 1s, number systems are broadly applied in various fields for calculations, measurements, and labeling, among other uses. There are several types of number systems, each suited to different applications.

## Takeaways

A number is nothing but symbols like 1, 2, 3, .. that can be used to perform calculations on them. A number can be written in a numeric form as well as in word form.

## What is Number System?

A number is a mathematical object used to count, measure, and label. It is a fundamental concept in mathematics, serving as a building block for various operations and theories. Numbers can be represented in different forms, such as integers, fractions, and decimals, and they can be positive, negative, or zero. They are essential for performing arithmetic operations like addition, subtraction, multiplication, and division, and they play a critical role in shaping mathematical principles and applications in various fields.

## Types of Numbers

When we are talking about numbers, we mainly refer to the decimal number systems (having numbers between 0 and 9`). So, there are various types of numbers in the decimal number system. Let us discuss them briefly.

**Positive Numbers**: The numbers that are greater than zero are known as positive numbers. In other words, the numbers that are present on the right-hand side of the zero on the number line are termed positive numbers. Example: 1, 2, 3, 4, etc.**Negative Numbers**: The numbers that are lesser than zero are known as negative numbers. In other words, the numbers that are present on the left-hand side of the zero on the number line are termed negative numbers. Example: -1, -2, -3, -4, etc.**Natural Numbers**: The most basic types of numbers that range from 1 to positive infinity are called natural numbers. Natural numbers are represented by**N**. Natural numbers are positive numbers without zero. Example: 1, 2, 3, 4, etc.**Whole Numbers**: The numbers that range between 0 to positive infinity are called whole numbers. Whole numbers are represented by**W**. Whole numbers are positive numbers including zero or natural numbers added with zero. Example: 0, 1, 5, 8, etc.**Fractional Numbers**: Fractional numbers are a part of whole numbers that are represented in the form of p/q, where p is known as the numerator and q is known as the denominator. Example:“ 1/2, 5/3, 3/4, /7/8`, etc.**Integer Numbers**: The integer numbers are a collection of positive values, negative values, and zero. Integer numbers include decimal point numbers but fractional numbers (numbers of the form numerator/denominator ) is not a part of integers numbers. Integer numbers are represented by**Z**. The range of integer numbers is from negative infinity to positive infinity including the number zero. Example: 1.5, -3.6, 7, -8, 0, etc.**Prime Numbers**: The number that can be completely divided by one and the number itself only is called a prime number. In other words, we can say that prime numbers have only two factors i.e. one and the number itself. Example: 3, 17, 23, 67 etc.**Composite Numbers**: The number that can be completely divided by one or more numbers apart from 1 and the number itself is called a composite number. In other words, we can say that composite numbers have more than two factors. Example: 32, 8, 25, 6 etc.**Even Numbers**: The positive or negative numbers that can be completely divided by the number 2 are known as even numbers. Example: 2, 4, 18, 26, etc.**Odd Numbers**: The positive or negative numbers that cannot be completely divided by the number 2 are known as even numbers. Example: 3, 13, 11, 17, etc.**Rational Numbers**: The number that can be represented in the form of p/q where p and q both are integers and q is not equal to 0, is called a rational number. Example: 10/2, 0.5, etc.**Irrational Numbers**: The number that cannot be represented in the form of p/q where p and q both are integers, is called an irrational number. Example: the value of pi, the value of root 2, etc.**Real Numbers**: Real numbers are the combination of rational numbers and irrational numbers. The real numbers are represented by**R**. Hence, real numbers can be both positive and negative.

Refer to the **complete chart of numbers** given below for a better understanding.

**Note:** All the fractional numbers are rational numbers but vice versa is not true.

## Types of Number System

Now, there are various types of number systems that have their use cases. Let us discuss them briefly.

Refer to the **complete chart of number systems** given below for a better understanding.

### 1. Decimal

The decimal number system or the base 10 number system uses 10 digits ranging from 0 to 9 to represent any number. The first position from the rightmost part of a decimal number is known as one’s place or unit’s place, then the second position is known as ten’s place, and so on. Every decimal number is represented by the power of base 10.

**For example**, the number 1457 is represented as:

**In the above example:**

- 7 is present at the unit’s place.
- 5 is present at ten’s place.
- 4 is present at hundred’s place.
- 1 is present at thousand’s place.

### 2. Binary

The binary number system or the base 2 number system uses only two digits i.e. 0 and 1 to represent any number. For example, the decimal number 14 is represented as 1110 in the binary number system. We need to keep dividing the decimal number by 2 until the quotient becomes 0 and along with that, we need to remember the remainder. When the remainders obtained in the division are represented in reverse order, a binary number is generated. Let us see how?

### 3. Octal

The octal number system or the base 8 number system uses 8 digits ranging from 0 to 7 to represent any number. The octal number is very commonly used the computer systems.

Every octal number is represented by the power of base 8.

**For example**, the number 215 is represented as:

### 4. Hexadecimal

The hexadecimal number system or the base 16 number system uses 16 digits ranging from **0 to 9** (i.e. 10 digits) and **A to F** (i.e. 6 digits) to represent any number. Refer to the chart shown below to know the representation of hexadecimal numbers.

We can convert a decimal number into a hexadecimal number. We need to keep dividing the decimal number by 16 until the remainder becomes 0 and along with that, we need to remember the remainder. When the remainders obtained in the division are represented in reverse order, the hexadecimal number is generated. Let us see how?

Refer to the image provided below to have a quick look at the base value of various number systems.

Refer to the next section to know how to convert decimal number systems into other number systems along with the implementation in C++, Java, and Python.

## Conversion of One Another

We can convert one number system to another number system. in this section, we will be learning about how to convert a decimal number system into the other number system with that we will be learning how to convert other number systems into the decimal number system.

### 1. Definition

As we have discussed earlier:

- The binary number system uses only two digits i.e. 0 and 1 to represent any number.
- The decimal number system uses ten digits from 0 to 9 to represent any number.
- The octal number system uses 8 digits ranging from 0 to 7 to represent any number.
- The hexadecimal number system uses 16 digits ranging from
**0 to 9**(i.e. 10 digits) and**A to F**(i.e. 6 digits) to represent any number.

### Let’s Now Learn about Conversion Between Number Systems

**Converting Decimal to Binary**:

**Step 1**: Divide the decimal number by 2, the base for binary numbers.**Step 2**: Record the remainder; this becomes the least significant digit (LSD) of the binary number.**Step 3**: Use the quotient as the new dividend and divide again by 2.**Step 4**: The new remainder becomes the next digit of the binary number, positioned to the left of the previous digit.- Repeat steps 3 and 4 until the quotient is 0. The last remainder obtained is the most significant digit (MSD).

**Example**: Convert decimal 13 to binary.

- 13 ÷ 2 = 6, remainder 1 (LSD)
- 6 ÷ 2 = 3, remainder 0
- 3 ÷ 2 = 1, remainder 1
- 1 ÷ 2 = 0, remainder 1 (MSD)

- Binary equivalent: 1101

**Converting Decimal to Octal**:

**Step 1**: Divide the decimal number by 8, the base for octal numbers.**Step 2**: The remainder becomes the least significant digit of the octal number.**Step 3**: The quotient is used as the new dividend, divided again by 8.**Step 4**: The new remainder becomes the next octal digit, positioned to the left of the previous digit.- Continue until the quotient is 0. The final remainder is the most significant digit.

**Example**: Convert decimal 95 to octal.

- 95 ÷ 8 = 11, remainder 7 (LSD)
- 11 ÷ 8 = 1, remainder 3
- 1 ÷ 8 = 0, remainder 1 (MSD)

- Octal equivalent: 137

**Converting Decimal to Hexadecimal**:

**Step 1**: Divide the decimal number by 16, the base for hexadecimal numbers.**Step 2**: The remainder becomes the least significant digit of the hexadecimal number. Use 0-9 for remainders 0-9 and A-F for remainders 10-15.**Step 3**: Use the quotient as the new dividend and divide by 16.**Step 4**: The new remainder becomes the next hexadecimal digit, to the left of the previous one.- Repeat steps until the quotient is 0, with the last remainder being the most significant digit.

**Example**: Convert decimal 254 to hexadecimal.

- 254 ÷ 16 = 15, remainder 14 (E, LSD)
- 15 ÷ 16 = 0, remainder 15 (F, MSD)

- Hexadecimal equivalent: FE

**Converting Binary to Decimal**:

**Step 1**: Starting from the right (least significant bit, LSB), multiply each binary digit by 2 raised to its position number, counting from 0.**Step 2**: Sum up the results of these multiplications to get the decimal equivalent.

**Example**: Convert binary 11101011 to decimal.

- Calculation: (1 * 2^7 + 1 * 2^6 + 1 * 2^5 + 0 * 2^4 + 1 * 2^3 + 0 * 2^2 + 1 * 2^1 + 1 * 2^0)
- Result: 128 + 64 + 32 + 0 + 8 + 0 + 2 + 1 = 235
- Decimal equivalent: 235

**Converting Binary to Octal**:

**Step 1**: Group the binary digits into sets of three, starting from the right. If necessary, pad the leftmost group with zeros to make it a trio.**Step 2**: Convert each trio into its octal equivalent, which will range from 0 to 7.

**Example**: Convert binary 11101011 to octal.

- Grouping: 1 110 101 011
- Converting each group: 1 is 1, 110 is 6, 101 is 5, 011 is 3
- Octal equivalent: 1653

**Converting Binary to Hexadecimal**:

**Step 1**: Divide the binary number into groups of four, starting from the right. Pad the leftmost group with zeros if it’s not already a quartet.**Step 2**: Convert each group into its hexadecimal equivalent, which will be in the range 0-9 and A-F for 10-15.

**Example**: Convert binary 1110101101101 to hexadecimal.

- Grouping: 1110 1011 0110 1
- Converting each group: 1110 is E, 1011 is B, 0110 is 6, 0001 is 1 (after padding)
- Hexadecimal equivalent: 1E6B

**Converting Octal to Decimal**:

**Step 1**: Starting from the right (least significant digit, LSD), multiply each octal digit by 8 raised to its position number, counting from 0.**Step 2**: Sum up these products to get the decimal equivalent.

**Example**: Convert octal 247 to decimal.

- Calculation: (2 * 8^2 + 4 * 8^1 + 7 * 8^0)
- Result: 128 + 32 + 7 = 167
- Decimal equivalent: 167

**Converting Octal to Binary**:

**Step 1**: Write down each octal digit separately.**Step 2**: Convert each octal digit into a corresponding group of three binary digits (bits).**Step 3**: Concatenate these binary groups to form the complete binary number.

**Example**: Convert octal 247 to binary.

- Octal digits: 2, 4, 7
- Binary equivalents: 010 (for 2), 100 (for 4), 111 (for 7)
- Binary equivalent: 010100111

**Converting Octal to Hexadecimal**:

**Step 1**: Convert the octal number to binary by following the steps for octal to binary conversion.**Step 2**: Group the binary digits into sets of four, starting from the right. If necessary, pad the leftmost group with zeros to make it a quartet.**Step 3**: Convert each binary group into its hexadecimal equivalent, using 0-9 for values 0-9 and A-F for values 10-15.

**Example**: Convert octal 5456 to hexadecimal.

- Convert to binary: 5456 octal = 101 100 101 110 binary
- Group into fours: 0101 1001 0111
- Convert each group: 0101 is 5, 1001 is 9, 0111 is 7

- Hexadecimal equivalent: 597

**Converting Hexadecimal to Decimal**:

**Step 1**: Understand the decimal values of hexadecimal symbols. For digits 0-9, the values are the same, and for letters A-F, they represent 10-15 respectively.**Step 2**: Multiply each digit of the hexadecimal number by 16 raised to its position number, starting from the right (LSB to MSB).**Step 3**: Sum up all the results from step 2 to get the decimal equivalent.

**Example**: Convert hexadecimal 8EB4 to decimal.

- Calculation: (8 * 16^3 + 14 * 16^2 + 11 * 16^1 + 4 * 16^0)
- Result: 36532
- Decimal equivalent: 36532

**Converting Hexadecimal to Binary**:

**Step 1**: Convert each hexadecimal digit to its decimal equivalent.**Step 2**: Convert each decimal digit to a 4-bit binary group.**Step 3**: Concatenate all the 4-bit groups to get the full binary number.

**Example**: Convert hexadecimal B2E to binary.

- Decimal equivalents: B=11, 2=2, E=14
- Binary conversions: B=1011, 2=0010, E=1110
- Binary equivalent: 101100101110

**Converting Hexadecimal to Octal**:

**Step 1**: Convert the hexadecimal number to binary by following the steps in the Hexadecimal to Binary conversion.**Step 2**: Group the binary digits into sets of three, starting from the right. If necessary, pad the leftmost group with zeros.**Step 3**: Convert each binary group to its octal equivalent.**Step 4**: Concatenate these octal digits to get the octal equivalent.

**Example**: Convert hexadecimal B2E to octal.

- First, convert B2E to binary: 101100101110
- Group into threes: 010 110 010 111
- Convert to octal: 2=010, 6=110, 2=010, 7=111
- Octal equivalent: 2627

## Conclusion

- Number systems represent numbers through symbols, pivotal in math and computing, with variations like binary (0s and 1s) crucial for digital systems.
- Positive and negative numbers denote values above and below zero, respectively, on the number line.
- Natural numbers start from 1, whole numbers include zero, and integers encompass both along with negative numbers.
- Prime numbers have only two factors (1 and themselves), while composite numbers have additional divisors.
- Rational numbers can be expressed as fractions, whereas irrational numbers cannot be represented as simple fractions.
- Decimal, binary, octal, and hexadecimal systems are used based on their applicability, with decimal for general arithmetic and others in specialized computing contexts.