In computers, the number system plays a crucial role in how data is stored and processed. At the core level, computers only understand 0’s and 1’s (binary form).
A number system is defined as the representation of numbers by using digits or other symbols in a consistent manner. We humans, use different number systems to represent numbers in different formats as convenient to us.
Types of Number systems

Decimal Number system
The decimal number system uses ten digits: 0,1,2,3,4,5,6,7,8 and 9 with the base number as 10. The decimal number system is the system that we generally use to represent numbers in real life. If any number is represented without a base, it means that its base is 10.

Binary Number System
The binary number system uses only two digits: 0 and 1. The numbers in this system have a base of 2. Digits 0 and 1 are called bits and 8 bits together make a byte. The data in computers is stored in terms of bits and bytes.


Number of bits and their data range

Say example, if we have 2 digits, we can represent numbers 0, 1, 2, 3.

Hexadecimal Number system
The hexadecimal number system uses sixteen digits/alphabets: 0,1,2,3,4,5,6,7,8,9 and A,B,C,D,E,F with the base number as 16. Here, A-F of the hexadecimal system means the numbers 10-15 of the decimal number system respectively. This system is used in computers to reduce the large-sized strings of the binary system.

Example : Below, Representing a long binary number using hex format [we go from Right to Left, grouping 4 bits. If you don’t have enough bits at the left, we do padding. ]:

Octal Number System
The octal number system uses eight digits: 0,1,2,3,4,5,6 and 7 with the base of 8. The advantage of this system is that it has lesser digits when compared to several other systems, hence, there would be fewer computational errors. [groups of 3 digits]


Code Example
Representing different number systems in code. In this code, we are trying to represent number 15 in different number systems. Note here that, the representation in computer memory is same for all these systems.

NOTE – binary number system representation (0b) is from C++14 onwards.
Summary
