In this tutorial we will learn about the different number systems.

## Introduction:

On computers, we typically use four different numbering systems:**Decimal, Binary, Octal and Hexadecimal.**

Is**decimal system**It is a number system used in our daily applications like business etc. In this system, the symbols 0,1,2,3,4,5,6,7,8,9 are used to denote different numbers.

inside**binary number system**,**0**j**1**They are the only symbols used to represent numbers of all magnitudes. For example a normal decimal number**7 (seven)**It is represented in binary as**111**. The binary system is mainly used in computers and other computing devices.

A number in a certain base is written as**(Number) _{Base}**. For example,

**(17)**is a decimal number (seventeen) and

_{10}**(10001)**is a binary number 10001, which actually represents a decimal number whose value is

_{2}**17**.

Because the decimal number system is more commonly used, the**Decimal (35) _{10}**it is simply written as 35. However, if the same number is to be represented in the

**Sense**system, it is written as

**(100011)**.

_{2}Likewise the**octal**Use of the number system**8**as a base. Typically used to indicate digits and represent file permissions on UNIX/Linux operating systems.

**hexadecimal**system that**Hex**is a number system that uses**sixteen**as a basis for representing numbers.

## 1. Decimal Numbers:

The numbers we use every day are among the**decimal system**. For example 0,1,2,3,4,…..,9999,…..etc. It is also called a**Basis – System 10**.

it's called the**Basis-10**Number system because it uses**10 unique digits**von**0 bis 9**to represent any number.

A**Base**(also called the**Base**) is the number of unique digits or symbols (**including 0**) used to represent a specific number.

in one**decimal system**(where the base is 10), a total of 10 digits (0,1,2,3,4,5,6,7,8, and 9) are used to represent any number of any size. For example,**A hundred and thirty five**is represented as**135**, Wo

135 = (1 * 10

^{2}) + (3 * 10^{1}) + (5 * 10^{0})135 = (1 * 100) + (3 * 10) + (5 * 1)

Similarly, fractions are represented using the base: 10 raised to a negative power.

## 2. Binary Numbers:

Is**binary number system**It is used in both mathematics and digital electronics.**The binary number system**Ö**Base - 2 number system**represents numeric values with only two symbols:**Null (0)**j**Like 1)**.

Computers have circuits (logic gates) that can be in one of two states:**OUT OF**Ö**IN**. These two states are represented by**Null (0)**j**Like 1)**or For this reason, the calculation is carried out in systems with a binary number system (base – 2), in which all numbers are represented with 0 and 1.

Every**binary number**, also Null (**0**) from uno (**1**) is called**Bit**(known as* B*I am you

*). A collection of*

**Is****8**such bits are called

**Byte**.

In computer terminology, multiples of different names have been given**2 ^{10}**(That means.,

**1024**multiplied by the currently existing value), as shown in the following table:

In the computer, texts, pictures, music, videos or any kind of data are ultimately stored in binary format on the hard drive.

In the binary system, a total of 2 digits (0 and 1) are used to represent a number of any size.

For example,**Null**is represented as 0, where

0 = (0 * 2

^{0}) = (0 * 1)

Similar,**Like**is represented as 1, where

1 = (1 * 2

^{0}) = (1 * 1)

Now let's represent the following numbers in binary format:

**Of the**(2): Since 0 and 1 are the only digits that can be used to represent 2, we divide 2 by 2 and write the quotient and the remainder as follows:

[Quotient][Rest], also : [1][0]

2 = (1 * 2

^{1}) + (0 * 2^{0}) = (2) + (0)

**Three**(3): Since 0 and 1 are the only digits that can be used to represent 3, we divide 3 by 2 and write the quotient and the remainder as follows:

[Quotient][Rest], also :[1][1]

3 = (1 * 2

^{1}) + (1 * 2^{0}) = (2) + (1)

**Seventeen**(17): Since 0 and 1 are the only digits that can be used to represent 17, we divide 17 by 2 and write the quotient and the remainder as follows:

[quotient][remainder], i.e.:[8][1], repeating the above logic for 8(8 = [4][0]), 4(4 = [2][0]),2(2 = [ 1][0]) and 1(1 = [0][1]), we finally get [1][0][0][0][1].

17 = (1 * 2

^{4}) + (0 * 2^{3}) + (0 * 2^{2}) + (0 * 2^{1}) + (1 * 2^{0})17 = (16) + (0) + (0) + (0) + (1)

In**C,**Binary numbers are prefixed**0b (or 0B)**(Number zero followed by the letter 'b'). For example, to store a binary value of four in a variable**binary_four,**We write

`int binary_Four = 0b100;`

## 3. Octal Numbers:

The numbering system you are using**Basis-8**it's called the**octal system.**A base (aka root) is the number of unique digits or symbols (including 0) used to represent a given number.

In the octal (or base-8) system, a total of 8 digits (0, 1, 2, 3, 4, 5, 6, and 7) are used to represent a number of any size (size).

For example,**Null**is represented as**0**, Wo

0 = (

0* 8^{0}) = (0* 1)

In the same way, the numbers 1, 2, … and 7 are represented below:

1 = (

1* 8^{0}) = (1* 1)2 = (

2* 8^{0}) = (2* 1)……

7 = (

7* 8^{0}) = (7* 1)

Now let's represent the following numbers in the octal system:

**Eighteen**(18): Since 0 through 7 are only digits that can be used to represent 18, we divide 18 by 8 and write the quotient and the remainder as follows:

[Quotient][Rest], also:

[2][2]18 = (

2* 8^{1}) + (2* 8^{0}) = (16) + (2)

**Four hundred twenty one**(421): Since 0 through 7 are only digits that can be used to represent 421, we divide 421 by 8 and write the quotient and the remainder as follows:

[Quotient][Rest], also: [52]

[5](Dividing plus 52 by 8 gives us[6][4]), which[6][4][5]421 = (6 * 8

^{2}) + (4 * 8^{1}) + (5 * 8^{0}) = (384) + (32) + (5)

To distinguish them from decimal numbers, octal numbers are prefixed.**0**(null).

For example, to store an octal value of seven in a variable**octal_seven**, We write

`int octal_seven = 07;`

Similarly, if we want to store an octal representation of a decimal number 9 in a variable**number nine,**We write

`int number_nine = 011;`

The largest digit in the octal system is**(7) _{8}**. number 7)

_{8}In binary format it is represented as

**(111)**. In the binary system, three binary digits (bits) are used to represent the highest octal digit. When converting a

_{2}**octal number**still

**binary number**,

**three bits**are used to represent each octal digit.

The table below shows the conversion of each octal digit to its corresponding binary digits.

For example an octal number**0246**is converted to the equivalent binary form as

`Octal number -> 2 4 6 Binary number -> 010 100 110`

For this reason**0246**es**(010100110) _{2}**.

Likewise when converting from a**Sense**number in its octal form, the binary number is divided into groups of**3 digits**respectively, starting at the far right of the given number. Each of the**three binary digits**is replaced by the appropriate one**The octal digit**.

If the leftmost group of binary digits in the number does not have three digits, the required number of zeros are added as a prefix to make three binary digits. For example, we convert a**Binary number 1101100**in its correspondence**octal**Number.

`Binary number -> 1 101 100 Binary number -> 001 101 100 //After leading zeros to the left end of the group Octal number -> 1 5 4`

Hence the octal equivalent of the given binary number**1101100**es**0154**.

## 4. Hexadecimal Numbers:

The number system you use**Basis-16**is called**hexadecimal system**or simply**hex.**A base (aka root) is the number of unique digits or symbols (including 0) used to represent a given number.

In the hexadecimal system (or**Basis-16**number system) a total of 16 symbols are used. Digits from**0 null)**A**9 neun)**are used to represent values of**0 bis 9**or alphabets**A**,**B**,**C**,**D**,**mi**j**F**(Ö**A**,**B**,**C**,**D**,**mi**, j**F**) are used to represent values of**10 bis 15**or.

In many programming languages**0x**used as a prefix to indicate a hexadecimal representation.

For example, in hexadecimal, the value of**null**is represented as**0x0**, Wo

0 = (

0* sixteen^{0}) = (0* 1)

Similar,

1 = (

1* sixteen^{0}) = (1* 1)2 = (

2* sixteen^{0}) = (2* 1)…..

15 =

F= (15* sixteen^{0}) = (15* 1)

Now let's represent the following numbers in hexadecimal:

decimal number**eighteen (18)**:

since it can only be used**0 bis 9**and alphabets**A ein F**18 represented.

We divide 18 by 16 and write the quotient and the remainder as follows:

[quotient][remainder], that is,

[1][2]18 =

0x12= (1* sixteen^{1}) + (2* sixteen^{0}) = (16) + (2)

**hundred sixty**(160).

since it can only be used**0 bis 9**and alphabets**A ein F**160 represent.

Let's divide 160 by 16 and write the quotient and the remainder as follows:

[quotient][remainder], i.e. [10][0], [A][0] (since 10 is represented by A)

160 =

0xA0 =(10* sixteen^{1}) + (0* sixteen^{0}) = (160) + (0)

Please note that both**capital letter**j**lowercase letters**Letters can be used to represent hexadecimal values. For example,

`int hex_One Hundred_and_Sixty = 0xA0; // or 0Xa0, but 0xA0 is preferred.`

The highest digit in hexadecimal format is**(F) _{sixteen}**. The number (F)

_{sixteen}In binary format it is represented as

**(1111)2**. Here,

**four binary digits**(bits) are used to represent the highest hexadecimal digit. In

**hexadecimal to binary**transformation,

**four bits**are used to represent each

**hexadecimal digit**.

The following table shows the respective conversions**hexadecimal digit**in its correspondence**binary numbers**.

For example hexadecimal number**0x5AF6**is converted to the equivalent binary form as follows:

`Hexadecimal number -> 5 A F 6Binary number -> 0101 1010 1111 0110`

For this reason,**0x5AF6**es**(0101101011110110) _{2}**.

Likewise, when converting a binary number to hexadecimal, the binary number is first divided into groups of 4 digits, each beginning on the far right. Each of the four binary digits is replaced with the corresponding hexadecimal digits.

If the group on the far left of**binary numbers**has not**Four Digits**, the required number of zeros are added as a prefix to form a group of four binary digits.

For example, let's convert the following binary**1101100**Number in hexadecimal format.

`Binary number -> 110 1100 Binary number -> 0110 1100 //After leading zeros in the leftmost group Hexadecimal number -> 6 C`

Hence the hexadecimal equivalent of the specified binary number**1101100**es**0x6C**.

## References:

Have fun learning 🙂

### related posts

- Java binary to decimal converter
- Java program to convert decimal numbers to octal numbers
- Java octal to decimal converter
- Example of Python number systems
- Java program to convert decimal to binary numbers
- Java program to convert decimal numbers to hexadecimal numbers
- Java binary to hexadecimal converter
- Convert any number to a Python binary number
- Java program for binary addition
- Sample Java 7 binary literal tutorials
- Java program to check octal number
- Binary search with Java
- Example tutorials on PHP data types
- Underscores in numeric literals Java 7
- Program C: Addition of digits of a given number up to a single digit