Various carry-system conversions

Source: Internet
Author: User

The numbers are followed by different letters to denote different rounding. B (binary) represents the binary, O (octal) represents octal, D (decimal) or no decimal, and H (hexadecimal) denotes hexadecimal.

Example: (101011) b= (o=) d= (2B) H

    • Binary → Decimal

Methods: Binary number from low to high (that is, from right to left) calculation, the No. 0 position of the weight is 2 0 square, the 1th bit of the weight is 2 1 square, 2nd-digit weight is 2 2 times, successively increment, the final result added value is the decimal value.

Example: To convert a binary (101011) b to decimal, proceed as follows:

1. No. 0 bit 1 x 2^0 = 1;

2.1th bit 1 x 2^1 = 2;

3.2nd bit 0 x 2^2 = 0;

4.3rd bit 1 x 2^3 = 8;

5.4th bit 0 x 2^4 = 0;

6.5th bit 1 x 2^5 = 32;

7. Reading, add the result value, 1+2+0+8+0+32=43, i.e. (101011) b= D.

Octal → Decimal

Methods: Octal number from low to high (that is, from right to left) calculation, the No. 0 position of the weight is 8 0 square, the 1th bit of the weight is 8 1 square, 2nd-digit weight is 8 2 times, successively increment, the final result added value is the decimal value.

Octal is every 8 into 1, octal number uses 0~7 this eight number to express a number.

Example: The steps to convert octal o to decimal are as follows:

1. No. 0 bit 3 x 8^0 = 3;

2.1th bit 5 x 8^1 = 40;

3. Reading, add the result value, 3+40=43, i.e. (o=) D.

    • Hex → Decimal

Methods: Hexadecimal number from low to high (that is, from right to left) calculation, the weight of the No. 0 bit is 16 of the 0, the 1th is 16 of the weight of 1 square, 2nd-digit weight is 16 of the square, successively increment, the final result added value is the value of the decimal.

Hexadecimal is every 16 in 1, hex of 16 number is 0123456789ABCDEF.

Example: The steps to convert Hex (2B) h to decimal are as follows:

1. No. 0 bit B x 16^0 = 11;

2.1th bit 2 x 16^1 = 32;

3. Reading, add the result value, 11+32=43, i.e. (2B) h= D.

    • Decimal → Binary

Methods: In addition to the 2 method, that is, each time the integer part divided by 2, the remainder is the number of the right, and the quotient continues to divide by 2, the remainder is the number of the last bit, this step continues until the quotient is 0, the last reading, from the last remainder read, until the first remainder.

Example: The steps to convert decimal (d) to binary are as follows:

1. Divide quotient 43 by 2 and quotient 21 to 1;

2. Divide quotient 21 by 2 and quotient 10 to 1;

3. Divide quotient 10 by 2 and quotient 5 to 0;

4. Divide quotient 5 by 2 and quotient 2 to 1;

5. Divide quotient 2 by 2 and quotient 1 to 0;

6. Divide quotient 1 by 2 and quotient 0 to 1;

7. Reading, since the last one is obtained by dividing the number of times by 2, so it is the highest, reading the numbers from the last remainder to read forward, 101011, i.e. (d=) B.

    • Decimal → Octal

Methods: In addition to the 8 method, that is, each time the integer part divided by 8, the remainder is the number of the right, and the quotient continues to divide by 8, the remainder is the number of the last bit, this step has been continued until the quotient is 0, the last reading, from the last remainder, up to the front of a remainder.

Example: The steps to convert decimal (796) d to octal are as follows:

1. Divide quotient 796 by 8 and quotient 99 to 4;

2. Divide quotient 99 by 8 and quotient 12 to 3;

3. Divide quotient 12 by 8 and quotient 1 to 4;

4. Divide quotient 1 by 8 and quotient 0 to 1;

5. The reading, since the last one is obtained by dividing multiple times by 8, so it is the highest, reading the number from the last remainder to read forward, 1434, i.e. (796) d= (1434) O.

    • Decimal → hexadecimal

Method 1: In addition to the 16 method of extraction, that is, each time the integer portion divided by 16, the remainder is the number of the right, and the quotient continues to divide by 16, the remainder is the number of the last bit, this step continues until the quotient is 0, the last reading, from the last remainder, until the first remainder.

Example: the steps for converting decimal (796) d to 16 are as follows:

1. Divide quotient 796 by 16 and quotient 49 to 12, corresponding to hexadecimal C;

2. Divide quotient 49 by 16 and quotient 3 to 1;

3. Divide quotient 3 by 16 and quotient 0 to 3;

4. Reading, because the last one is obtained by dividing it by 16 times, so it is the highest, reading the number from the last remainder to read forward, 31C, i.e. (796) d= (31C) H.

    • Binary → Octal

Methods: Take the three-way method, that is, from the decimal point of the binary points to the left (right) every three bits taken into one, and then the three-bit binary by the right to add, and then, in order to arrange, the position of the decimal point is unchanged, the resulting number is the octal number we asked for. If you take three bits to the left (right) and take the highest (lowest) bit, if you cannot make up three bits, you can add 0 to the leftmost (rightmost) of the decimal point, the highest bit of the integer (the lowest bit), and fill three bits.

Example: The steps to convert binary (11010111.0100111) b to octal are as follows:

1.111 = 7 before the decimal point;

2.010 = 2;

3.11 complement is 011,011 = 3;

4.010 = 2 after the decimal point;

5.011 = 3;

6.1 complement is 100,100 = 4;

7. Readings, readings from high to low, i.e. (11010111.0100111) b= (327.234) O.

Binary and Octal encoding correspondence table:

Binary

Octal

000

0

001

1

010

2

011

3

100

4

101

5

110

6

111

7

    • octal → Binary

Method: Take a three-way, will be a octal number decomposition into three-bit binary number, with three-bit binary right add to the octal number, the decimal place as usual.

Example: The steps to convert octal (327) O to binary are as follows:

1.3 = 011;

2.2 = 010;

3.7 = 111;

4. Readings, readings from high to low, 011010111, i.e. (327) o= (11010111) B.

    • Binary → hexadecimal

Methods: Take four in one method, that is, from the decimal point of the binary point to the left (to the right) every four bits, and then the four-bit binary by the right to add, and then, in order, the position of the decimal point is unchanged, the resulting number is the hexadecimal number we ask for. If you take four bits to the left (right) and take the highest (lowest) bit, if you cannot make up four bits, you can add 0 to the leftmost (rightmost) of the decimal point, the highest bit of the integer (the lowest bit), and fill four bits.

Example: Converting binary (11010111) b to 16 binary is as follows:

1.0111 = 7;

2.1101 = D;

3. Readings, readings from high to low, i.e. (11010111) b= (D7) H.

    • Hex → Binary

Method: Take a four-way, will be a hexadecimal number decomposition into four-bit binary number, with four-bit binary right add to the hexadecimal number, the decimal place as usual.

Example: The steps to convert Hex (D7) h to binary are as follows:

1. D = 1101;

2.7 = 0111;

3. Readings, readings from high to low, i.e. (D7) h= (11010111) B.

    • Octal → Hex

Method: Converts octal to binary, then converts the binary to 16, and the decimal point is unchanged.

Example: The steps to convert octal (327) O to 16 are as follows:

1.3 = 011;

2.2 = 010;

3.7 = 111;

4.0111 = 7;

5.1101 = D;

6. Readings, readings from high to low, D7, i.e. (327) o= (D7) H.

    • Hex → Octal

Method: Convert the 16 binary to binary, then convert the binary to octal, and the decimal point position is unchanged.

Example: The steps to convert Hex (D7) h to octal are as follows:

1.7 = 0111;

2. D = 1101;

3.0111 = 7;

4.010 = 2;

5.011 = 3;

6. Readings, readings from high to low, 327, i.e. (D7) h= (327) O.

Various carry-system conversions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.