1. What is Number System in PHP?
2. How many types of Number System in PHP?
3. What is Binary Number System and Bit?
4. What is Octal Number System?
5. What is Decimal Number System?
6. What is Hexa Decimal Number System?
7. How to convert Decimal to Binary and Binary to Decimal Number?
8. How to convert Decimal to Octal and Octal to Decimal Number?
9. How to convert Decimal to Hexa Decimal and Hexa Decimal to Decimal Number?
10. Is there any different rule for writing Binary, Octal, Decimal, Hexadecimal number in PHP?

What is Number System in PHP?

Numbering system in PHP or any programming language is a way to show or represent our daily used numbers by dividing them into different groups based on the maximum number or base and approved numbers.

How many types of Numbering System in PHP?

Number System 4 types in PHP:

What is Binary Number System and Bit?

Binary means two (2), meaning it is a numbering system in which all the numbers are expressed with only 0 and 1. All in all, since 0 and 1 are the two digits used in it, it is called Binary Numbering System. Using these two numbers i.e. 0 and 1, the computer processes all the information, solves mathematical problems, stores the information i.e. performs all kinds of tasks.

When we write and execute a program on a computer, the computer processes all the commands by converting them to 0 and 1. Binary Numbering System has two bases (2). In binary system each number is called a bit.

What is Octal Number System?

Octal means octave or 8, meaning it is a numbering system in which all numbers are expressed with only 0 to 7. All in all, since it uses these eight digits from 0 to 7, it is called Octal Numbering System. It basically groups binary numbers into three digits (eg: 000,001,010,011,100,101,110,111) to process different types of data on the computer, solve mathematical problems, store data, that is, perform various tasks. The basis of Octal Numbering System is eight (8).

What is Decimal Number System?

Decimal means decimal or 10, meaning it is a Numbering System in which all Numbers are expressed with only 0 to 9. All in all, since it uses these 10 digits 0,1,2,3,4,5,6,7,8,9 it is called Decimal Numbering System. It basically processes different types of information in our daily life, solves mathematical problems i.e. performs different tasks. The basis of decimal numbering system is ten (10).

What is Hexadecimal Number System?

Hexa Decimal means sixteen or 16, meaning it is a numbering system in which all numbers are expressed with only 0 to 15. The sixteen numbers in this method are 0,1,2,3,4,5,6,7,8,9 and 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F , Since it uses these 16 digits from 0 to 15, so it is called Hexadecimal Numbering System.

It basically binary numbers are grouped into four digits (eg: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111). Performs, performs mathematical problems, stores information, that is, performs various tasks. The basis of Hexadecimal Numbering System is ten (18).

How to convert Decimal to Binary and Binary to Decimal Number?

Rules for Converting Decimal Numbers to Binary Numbers:

1. The number to be converted to binary must be divided by 2
2. You have to take whatever is left over, if it is 0 you have to take it
3. The quotient that will come will have to be divided again by 2
4. You have to take whatever is left over, if it is 0 you have to take it
5. The quotient that will come will have to be divided again by 2
6. You have to take whatever is left over, if it is 0 you have to take it
7. Thus the quotient has to be divided by 2 until it comes to 1
8. If you get the quotient 1, the binary number will be 1 and all the
9. divisions from bottom to top will be a number sitting side by side.

Example 1: Convert 16 to Binary

16 ÷ 2 = 8; The remainder is 0

8 ÷ 2 = 4; The remainder is 0

4 ÷ 2 = 2; The remainder is 0

2 ÷ 2 = 1; The remainder is 0

In the case of 16 the binary number = 10000

Example 2: Converting 17 to Binary

17 ÷ 2 = 8; Quotient 1

8 ÷ 2 = 4; The remainder is 0

4 ÷ 2 = 2; The remainder is 0

2 ÷ 2 = 1; The remainder is 0

Binary number in case of 17 = 10001

Conversion from Binary Number to Decimal Number

The bits to the left of the binary number on the right have to be multiplied by their local values.

Then the product of the product is the decimal number.

Example: Convert 10001 to Decimal Number

1 × 1 = 1

0 × 2 = 0

0 × 4 = 0

0 × 8 = 0

1 × 16 = 16

Decimal Number = 1 + 0 + 0 + 0 + 16 = 17

How to convert Decimal to Octal and Octal to Decimal Number?

Rules for Converting Decimal Number to Octal Number:

• The number to be converted to Octal must be divided by 8
• You have to take what will be the remainder, if it is 0, you have to take it
• The quotient will be divided by 8 again
• Thus the remainder should be divided by 8 until any number of 7 or less is expected
• If the quotient gets any number of 7 or less, the Octal Numbers will be the last quotient and all the quotations from bottom to top will be sitting side by side.

Example 1: Convert 139 to Octal

139 ÷ 8 = 17; Quotient 3

17 ÷ 8 = 2; Quotient 1

Octal number in case of 139 = 213

Conversion from Octal Number to Decimal Number

The bits on the left side of the Octal Number have to be multiplied by the local value of 8.

Then the product of the product is the decimal number.

Example: Convert 213 Octal Number to Decimal Number

Octal 213 = (2 * 82) + (1 * 81) + (3 * 80) = 2 * 64 + 1 * 8 + 3 * 1

Octal Number: 213 = 128 + 8 + 3 = 139 Decimal

How to convert Decimal to Hexadecimal and Hexadecimal to Decimal Number?

Rules for Converting Decimal Numbers to Hexadecimal Numbers:

• The number to be converted to Hexadecimal must be divided by 16
• You have to take what will be the remainder, if it is 0, you have to take it
• The quotient will have to be divided again by 16
• Thus the remainder should be divided by 8 until any number of 15 or less is expected
• If the quotient gets any number of 15 or less, the Octal Numbers will be the last quotient and all the fractions from bottom to top will be formed sitting side by side. However, the numbers after 0-9 should be 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F respectively.

Example 1: Converts 17 to Hexadecimal

17 ÷ 16 = 1; Quotient 1

Hexadecimal number in case of 17 = 11

Conversion from Hexadecimal Number to Decimal Number

The bits on the left side of the Hexadecimal Number must be multiplied by the local value of 16.

Then the product of the product is the decimal number.

Example: Convert 11 or C Hexadecimal Number to Decimal Number

Hexadecimal 11 = B = (1 * 161) + (1 * 160) = 1 * 16 + 1 * 1

Hexadecimal Number: 11 = B = 16 + 1 = 17 Decimal

Is there any different rule for writing Binary, Octal, Decimal, Hexadecimal number in PHP?

Yes, PHP has different rules for each e-numbering system. Notice the table below:

An example:

Explanation: Notice in the example above, the first number is 11 Decimal then 011 number starts with 0 because Octal whose decimal value is “(1 * 81) + (1 * 80) = 9 ″ 9 then 0b11 number starts with 0b. Binary whose Decimal value is “(1 * 21) + (1 * 20) = 3 ″ 3 The last 0x11 number starts with 0x so it is Hexadecimal whose Decimal value is“ (1 * 161) + (1 * 160) = 17 ″ 17. So the result is (11 + 9 + 3 + 17 = 40)