The Number system is a technique to represent and work with numbers. The decimal is the most common number system among other popular number systems like binary, octal, hexadecimal, etc.

Digital and Electronic systems may use various number systems like Decimal, Hexadecimal, Octal, and Binary. We can write a number N in base or radix b as:

Here, dn-1 to d0 is the integer part, follows a radix point, and d-1 to d-m is the fractional part.

d_{n-1} is the Most significant bit (MSB)

d_{-m} is the Least significant bit (LSB)

Here is a list of some of the number systems used in computer science:

Decimal Number System

The decimal number system is a base 10 number system having ten digits from 0 to 9. It means that we can represent any numerical quantity using these ten digits. The decimal number system is also a positional value system. It means that the value of digits will depend on their position.

Binary Number System

The easiest way to run instructions through electric signals is a two-state system â€“ on and off. On is represented as 1 and off as 0, though 0 is no signal but a lower voltage signal. The number system having only these two digits (0 & 1) is called a binary number system.

The rightmost digit is the LSB(least significant bit) in any binary number, and the leftmost digit is the MSB(most significant bit).

Octal Number System

The octal number system has eight digits - 0, 1, 2, 3, 4, 5, 6, and 7. The octal number system is a positional value system where each digit is expressed in powers of 8.

Hexadecimal Number System

The octal number system has 16 symbols from 0 to 9 and A to F where A is equal to 10 and B is equal to 11, until F. The Hexadecimal number system is also a positional value system where each digit has its value expressed in powers of 16.

The following table shows the association between binary, octal, decimal, and hexadecimal number systems.

BINARY

DECIMAL

OCTAL

HEXADECIMAL

0000

0

0

0

0001

1

1

1

0010

2

2

2

0011

3

3

3

0100

4

4

4

0101

5

5

5

0110

6

6

6

0111

7

7

7

1000

8

10

8

1001

9

11

9

1010

10

12

A

1011

11

13

B

1100

12

14

C

1101

13

15

D

1110

14

16

E

1111

15

17

F

Base Conversions

Here are a few of the most used base conversions:

Decimal to Binary

Step 1: Firstly, divide the decimal number by two and note the remainder.

Step 2: Divide the obtained quotient by 2, and note the remainder again.

Step 3: Then repeat the above steps until the quotient is 0.

Step 4: Write the remainders so that the last remainder is written first, followed by the rest in the reverse order.

Step 5: We can also understand this differently: the binary number's LSB(Least Significant Bit) is at the top, and the MSB(Most Significant Bit) is at the bottom. This number is the binary value of the given decimal number.

For Example: 13_{10} = 1101_{2}

Division by 2

Quotient

Remainder

13 Ã· 2

6

1 (LSB)

6 Ã· 2

3

0

3 Ã· 2

1

1

1 Ã· 2

0

1 (MSB)

Binary to Decimal

The general formula for converting binary numbers to decimal numbers is:

We divide a decimal number by eight each time we get a reminder from the previous digit.

Let us take a decimal number, i.e., 350.

Step 1: Check if the decimal number is less than 8. If yes, the octal number is the same. If no, then proceed forward. In this case, 350 is more than eight, so let's go to step 2.

Step 2: Divide 350 by 8 (octal base number). Note the quotient and the remainder in the quotient-remainder form. Repeat this process until we get the quotient to be less than 8.

Step 3: Once we obtain the quotient less than 8, we stop dividing to derive the octal number. The octal number is considered by reading all the remainders and the last quotient from bottom to top.

Therefore, 350_{10} = 536_{8}

Octal to Decimal

Step 1: Write 140.2 with the power of 8. Start from the right-hand side.

Besides numerical data, a computer must handle alphabets, punctuation marks, mathematical operators, special symbols, etc., that form the complete character set of the English language. The full set of characters or symbols is called alphanumeric codes. The complete alphanumeric code typically includes

26 upper case letters

26 lower case letters

10 numeral digits

7 punctuation marks

20 to 40 special characters

A computer understands only numeric values, whatever we use the number system. So all characters should have a numeric equivalent or an alphanumeric code. The most widely used alphanumeric code is ASCII or American Standard Code for Information Interchange. ASCII is a 7-bit long code with 128 (27) potential codes.

What are Number Systems? Number systems are a way of writing to express numbers. It is the mathematical notation representing numbers of a given set consistently using digits or other symbols. It delivers a unique representation of every integer and represents the arithmetic and algebraic structure of the figures.

Define ISCII and UNICODE? ISCII stands for Indian Script Code for Information Interchange. We developed IISCII to support Indian languages on the computer. Language supported by IISCI includes Devanagari, Tamil, Bangla, Gujarati, Gurmukhi, Tamil, Telugu, etc. Government departments mostly use IISCI, and before it could catch on, a new universal encoding standard named Unicode came into play. Unicode is an international coding system designed with different language scripts. Each character or symbol is assigned a unique numeric value, mainly within the framework of ASCII. Earlier, each script had its encoding system, which could conflict.

What are the advantages of the number systems in computers? Computer language utilizes a binary number system with zero representing an 'off' state and one representing an 'on' form. Benefits include ease of use in coding, fewer computations, and fewer computational errors. We can also use the binary number system in Boolean algebra.

Why is Hexadecimal used? Hexadecimal is a base 16 system used to simplify representing binary. It means we can write an 8-bit binary number using only two hex digits, one hex digit for each nibble (or group of 4-bits). It is easier to write numbers as hexes than as binary numbers.

Can computers use base 10? In theory, computers could use base 10, and some did historically. Any signal in a computer is voltage differentials. In a base-2 computer, there's low voltage and high voltage, corresponding to numeric 0 and 1, respectively.

Key Takeaways

This article teaches about Number Systems and how we use them. We saw types and interconversion of number systems and their value in programming.

For more information and dive deep into the world of programming, visit our guided path for ultimate guidance.

If you are preparing for your DSA interviews, then, Coding Ninjas Studio is a one-stop destination. This platform will help you acquire effective coding techniques and overview student interview experience in various product-based companies.