Conversion between bases of computer network (binary, octal, decimal, hexadecimal)

Conversion between bases of computer network (binary, octal, decimal, hexadecimal)

Before that, learn about the English representatives of each base system

  • Binary is Binary, abbreviated as B
  • Octal is Octal, abbreviated as O
  • Decimal is Decimal, abbreviated as D
  • Hexadecimal is Hexadecimal, abbreviated as H

1. Convert decimal to binary

The simple summary of converting decimal to binary is:

  • The integer part "divides the base and takes the remainder"
  • Fractional part "multiply base rounding"
  • Example 123.5D=________B
  • As shown in the figure below: directly divide the integer part of the formula 123 by the base 2 to get the remainder, and then take it from bottom to top, and finally get 1111011B. The decimal part is also multiplied by the base 2 to get the product, take out the integer part of the product, and then use 2 Multiply the remaining fractional part to get another product, and then take out the integer part of the product, and so on until the fractional part in the product is zero, or the required precision is reached, and finally 0.1B is obtained
  • Finally, after tidying up, we get 123.5D=1111011.1B

decimal to binary

2. Convert decimal to octal

  • Converting decimal to octal is exactly the same as converting decimal to binary
  • Just change the base 2 used when converting to binary to 8
  • The integer part "divides the base and takes the remainder"
  • Fractional part "multiply base rounding"
  • Example 123.5D=________O
  • The specific steps will not be demonstrated, you can try it, the final result is 123.5D=173.4O

3. Convert decimal to hexadecimal

  • Converting decimal to hexadecimal is exactly the same as converting decimal to binary
  • Just change the base 2 used when converting to binary to 16
  • The integer part "divides the base and takes the remainder"
  • Fractional part "multiply base rounding"
  • Example 123.5D=________H
  • The specific steps will not be demonstrated, you can try it, the final result is 123.5D=7b.8H

4. Convert binary to decimal

  • Expand by weight and add sequentially
  • Example 10101010B=_______D
  • Direct formula "expand according to weight and add sequentially"
  • The final result is 10101010B=170D

binary to decimal

5. Octal to Decimal

  • The idea of ​​converting octal to decimal is exactly the same as converting binary to decimal
  • Just change base 2 to 8
  • Example 21O=_______D
  • Finally get 21O=17DOctal to Decimal

6. Convert hexadecimal to decimal

  • Converting hexadecimal to decimal is exactly the same as converting binary to decimal
  • Just change base 2 to 16
  • Example 11abH=_______D
  • Finally, 11abH=4523D is obtained
    insert image description here

7. Convert binary to octal

  • take three in one
  • That is, from the binary decimal point as the dividing point, every three digits to the left (or right) are taken as one
  • If there are not enough digits, fill with 0

binary to octal

8. Binary to hexadecimal

  • take four in one
  • That is, from the binary point as the dividing point, every four digits to the left (or right) are taken as one
  • If there are not enough digits, fill with 0

binary to hexadecimal

9. At the end, attach the eight-digit binary value corresponding to the decimal system, which should be memorized proficiently

Base correspondence

Guess you like

Origin blog.csdn.net/qq_45893748/article/details/121103093