Convert hexadecimal number to binary online. Converting integers from one number system to another. Subtracting Binary Numbers

Methods for converting numbers from one number system to another.

Converting numbers from one positional number system to another: converting integers.

To convert an integer from one number system with base d1 to another with base d2, you must sequentially divide this number and the resulting quotients by base d2 of the new system until you get a quotient less than base d2. The last quotient is the highest digit of the number in new system numbers with base d2, and the numbers following it are remainders from division, written in the reverse order of their receipt. Perform arithmetic operations in the number system in which the number being translated is written.

Example 1. Convert the number 11(10) to the binary number system.

Answer: 11(10)=1011(2).

Example 2. Convert the number 122(10) to octal system Reckoning.


Answer: 122(10)=172(8).

Example 3. Convert the number 500(10) to hexadecimal system Reckoning.


Answer: 500(10)=1F4(16).

Converting numbers from one positional number system to another: converting proper fractions.

To convert a proper fraction from a number system with base d1 to a system with base d2, it is necessary to sequentially multiply the original fraction and the fractional parts of the resulting products by the base of the new number system d2. The correct fraction of a number in the new number system with base d2 is formed in the form of integer parts of the resulting products, starting from the first.
If the translation results in a fraction in the form of an infinite or divergent series, the process can be completed when the required accuracy is achieved.

When translating mixed numbers, it is necessary to separately translate the integer and fractional parts into a new system according to the rules for translating integers and proper fractions, and then combine both results into one mixed number in the new number system.

Example 1. Convert the number 0.625(10) to the binary number system.


Answer: 0.625(10)=0.101(2).

Example 2. Convert the number 0.6(10) to the octal number system.


Answer: 0.6(10)=0.463(8).

Example 2. Convert the number 0.7(10) to hexadecimal number system.


Answer: 0.7(10)=0.B333(16).

Convert binary, octal and hexadecimal numbers to the decimal number system.

To convert a number from the P-ary system to a decimal one, you must use the following expansion formula:
аnan-1…а1а0=аnPn+ аn-1Pn-1+…+ а1P+a0 .

Example 1. Convert the number 101.11(2) to the decimal number system.

Answer: 101.11(2)= 5.75(10) .

Example 2. Convert the number 57.24(8) to the decimal number system.

Answer: 57.24(8) = 47.3125(10) .

Example 3. Convert the number 7A,84(16) to the decimal number system.

Answer: 7A.84(16)= 122.515625(10) .


Converting octal and hexadecimal numbers to the binary number system and vice versa.

To convert a number from the octal number system to binary, each digit of this number must be written as a three-digit binary number (triad).

Example: write the number 16.24(8) in the binary number system.


Answer: 16.24(8)= 1110.0101(2) .

To convert a binary number back into the octal number system, you need to divide the original number into triads to the left and right of the decimal point and represent each group with a digit in the octal number system. Extreme incomplete triads are supplemented with zeros.

Example: write the number 1110.0101(2) in the octal number system.


Answer: 1110.0101(2)= 16.24(8) .

To convert a number from the hexadecimal number system to the binary system, you need to write each digit of this number as a four-digit binary number (tetrad).

Example: write the number 7A,7E(16) in the binary number system.


Answer: 7A,7E(16)= 1111010.0111111(2) .

Note: leading zeros on the left for integers and on the right for fractions are not written.

To convert a binary number back into the hexadecimal number system, you need to divide the original number into tetrads to the left and right of the decimal point and represent each group with a digit in the hexadecimal number system. Extreme incomplete triads are supplemented with zeros.

Example: write the number 1111010.0111111(2) in hexadecimal number system.

Write the number in the binary number system, and the powers of two from right to left. For example, we want to convert the binary number 10011011 2 to decimal. Let's write it down first. Then we write the powers of two from right to left. Let's start with 2 0, which is equal to "1". We increase the degree by one for each subsequent number. We stop when the number of elements in the list is equal to the number of digits in the binary number. Our example number, 10011011, has eight digits, so a list of eight elements would look like this: 128, 64, 32, 16, 8, 4, 2, 1

Write the digits of the binary number under the corresponding powers of two. Now simply write 10011011 under the numbers 128, 64, 32, 16, 8, 4, 2, and 1, so that each binary digit corresponded to its power of two. The rightmost "1" of the binary number must correspond to the rightmost "1" of the powers of two, and so on. If you prefer, you can write the binary number above powers of two. The most important thing is that they match each other.

Match the digits in a binary number with the corresponding powers of two. Draw lines (from right to left) that connect each successive digit of the binary number to the power of two above it. Start drawing lines by connecting the first digit of a binary number to the first power of two above it. Then draw a line from the second digit of the binary number to the second power of two. Continue connecting each number to the corresponding power of two. This will help you visually see the relationship between two different sets of numbers.

Write it down final value each power of two. Go through each digit of a binary number. If the number is 1, write the corresponding power of two under the number. If this number is 0, write 0 under the number.

  • Since "1" matches "1", it remains "1". Since "2" matches "1", it remains "2". Since "4" corresponds to "0", it becomes "0". Since "8" matches "1", it becomes "8", and since "16" matches "1" it becomes "16". "32" matches "0" and becomes "0", "64" matches "0" and therefore becomes "0", while "128" matches "1" and therefore becomes 128.
  • Add up the resulting values. Now add the resulting numbers under the line. Here's what you have to do: 128 + 0 + 0 + 16 + 8 + 0 + 2 + 1 = 155. This is the decimal equivalent of the binary number 10011011.

    Write the answer along with a subscript equal to the number system. Now all you have to do is write 155 10 to show that you are working with a decimal answer, which deals with powers of ten. The more you convert binary numbers to decimals, the easier it will be for you to remember powers of two, and the faster you will be able to complete the task.

  • Use this method to convert a binary number with a decimal point to decimal form. You can use this method even if you want to convert a binary number such as 1.1 2 to decimal. All you need to know is that the number on the left side of the decimal is a regular number, and the number on the right side of the decimal is the "halve" number, or 1 x (1/2).

    • "1" to the left of the decimal number corresponds to 2 0, or 1. 1 to the right of the decimal number corresponds to 2 -1, or.5. Add 1 and .5 and you get 1.5, which is the decimal equivalent of 1.1 2.
  • 1. Ordinal counting in various systems Reckoning.

    IN modern life we use positioning systems notation, that is, systems in which the number denoted by a digit depends on the position of the digit in the notation of the number. Therefore, in the future we will talk only about them, omitting the term “positional”.

    In order to learn how to convert numbers from one system to another, we will understand how sequential recording of numbers occurs using the example decimal system.

    Since we have a decimal number system, we have 10 symbols (digits) to construct numbers. We start counting: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The numbers are over. We increase the bit depth of the number and reset the low-order digit: 10. Then we increase the low-order digit again until all the digits are gone: 11, 12, 13, 14, 15, 16, 17, 18, 19. We increase the high-order digit by 1 and reset the low-order digit: 20. When we use all the digits for both digits (we get the number 99), we again increase the digit capacity of the number and reset the existing digits: 100. And so on.

    Let's try to do the same in the 2nd, 3rd and 5th systems (we introduce the notation for the 2nd system, for the 3rd, etc.):

    0 0 0 0
    1 1 1 1
    2 10 2 2
    3 11 10 3
    4 100 11 4
    5 101 12 10
    6 110 20 11
    7 111 21 12
    8 1000 22 13
    9 1001 100 14
    10 1010 101 20
    11 1011 102 21
    12 1100 110 22
    13 1101 111 23
    14 1110 112 24
    15 1111 120 30

    If the number system has a base greater than 10, then we will have to enter additional characters, it is customary to enter letters of the Latin alphabet. For example, for the 12-digit system, in addition to ten digits, we need two letters ( and ):

    0 0
    1 1
    2 2
    3 3
    4 4
    5 5
    6 6
    7 7
    8 8
    9 9
    10
    11
    12 10
    13 11
    14 12
    15 13

    2. Conversion from the decimal number system to any other.

    To translate a positive integer decimal number into a number system with a different base, you need to divide this number by the base. Divide the resulting quotient by the base again, and further until the quotient is less than the base. As a result, write down in one line the last quotient and all remainders, starting from the last.

    Example 1. Let's convert the decimal number 46 to the binary number system.

    Example 2. Let's convert the decimal number 672 to the octal number system.

    Example 3. Let's convert the decimal number 934 to the hexadecimal number system.

    3. Conversion from any number system to decimal.

    In order to learn how to convert numbers from any other system to decimal, let's analyze the usual notation for a decimal number.
    For example, the decimal number 325 is 5 units, 2 tens and 3 hundreds, i.e.

    The situation is exactly the same in other number systems, only we will multiply not by 10, 100, etc., but by the powers of the base of the number system. For example, let's take the number 1201 in ternary system Reckoning. Let's number the digits from right to left starting from zero and imagine our number as the sum of the products of a digit and three to the power of the digit of the number:

    This is the decimal notation of our number, i.e.

    Example 4. Let's convert to the decimal number system octal number 511.

    Example 5. Let's convert the hexadecimal number 1151 to the decimal number system.

    4. Transfer from binary system into a system with a base “power of two” (4, 8, 16, etc.).

    To convert a binary number into a number with a power of two base, it is necessary to divide the binary sequence into groups according to the number of digits equal to the power from right to left and replace each group with the corresponding digit of the new number system.

    For example, Let's convert the binary number 1100001111010110 to the octal system. To do this, we will divide it into groups of 3 characters starting from the right (since ), and then use the correspondence table and replace each group with a new number:

    We learned how to build a correspondence table in step 1.

    0 0
    1 1
    10 2
    11 3
    100 4
    101 5
    110 6
    111 7

    Those.

    Example 6. Let's convert the binary number 1100001111010110 to hexadecimal.

    0 0
    1 1
    10 2
    11 3
    100 4
    101 5
    110 6
    111 7
    1000 8
    1001 9
    1010 A
    1011 B
    1100 C
    1101 D
    1110 E
    1111 F

    5. Conversion from a system with the base “power of two” (4, 8, 16, etc.) to binary.

    This translation is similar to the previous one, made in reverse side: We replace each digit with a group of binary digits from the lookup table.

    Example 7. Let's convert the hexadecimal number C3A6 to the binary number system.

    To do this, replace each digit of the number with a group of 4 digits (since ) from the correspondence table, supplementing the group with zeros at the beginning if necessary:



    Note 1

    If you want to convert a number from one number system to another, then it is more convenient to first convert it to the decimal number system, and only then convert it from the decimal number system to any other number system.

    Rules for converting numbers from any number system to decimal

    IN computer technology, using machine arithmetic, an important role is played by the conversion of numbers from one number system to another. Below we give the basic rules for such transformations (translations).

      When converting a binary number to a decimal, it is required to represent the binary number as a polynomial, each element of which is represented as the product of a digit of the number and the corresponding power of the base number, in in this case$2$, and then you need to calculate the polynomial using the rules of decimal arithmetic:

      $X_2=A_n \cdot 2^(n-1) + A_(n-1) \cdot 2^(n-2) + A_(n-2) \cdot 2^(n-3) + ... + A_2 \cdot 2^1 + A_1 \cdot 2^0$

    Figure 1. Table 1

    Example 1

    Convert the number $11110101_2$ to the decimal number system.

    Solution. Using the given table of $1$ powers of the base $2$, we represent the number as a polynomial:

    $11110101_2 = 1 \cdot 27 + 1 \cdot 26 + 1 \cdot 25 + 1 \cdot 24 + 0 \cdot 23 + 1 \cdot 22 + 0 \cdot 21 + 1 \cdot 20 = 128 + 64 + 32 + 16 + 0 + 4 + 0 + 1 = 245_(10)$

      To convert a number from the octal number system to the decimal number system, you need to represent it as a polynomial, each element of which is represented as the product of a digit of the number and the corresponding power of the base number, in this case $8$, and then you need to calculate the polynomial according to the rules of decimal arithmetic:

      $X_8 = A_n \cdot 8^(n-1) + A_(n-1) \cdot 8^(n-2) + A_(n-2) \cdot 8^(n-3) + ... + A_2 \cdot 8^1 + A_1 \cdot 8^0$

    Figure 2. Table 2

    Example 2

    Convert the number $75013_8$ to the decimal number system.

    Solution. Using the given table of $2$ powers of the base $8$, we represent the number as a polynomial:

    $75013_8 = 7\cdot 8^4 + 5 \cdot 8^3 + 0 \cdot 8^2 + 1 \cdot 8^1 + 3 \cdot 8^0 = 31243_(10)$

      To convert a number from hexadecimal to decimal, you need to represent it as a polynomial, each element of which is represented as the product of a digit of the number and the corresponding power of the base number, in this case $16$, and then you need to calculate the polynomial according to the rules of decimal arithmetic:

      $X_(16) = A_n \cdot 16^(n-1) + A_(n-1) \cdot 16^(n-2) + A_(n-2) \cdot 16^(n-3) + . .. + A_2 \cdot 16^1 + A_1 \cdot 16^0$

    Figure 3. Table 3

    Example 3

    Convert the number $FFA2_(16)$ to the decimal number system.

    Solution. Using the given table of $3$ powers of the base $8$, we represent the number as a polynomial:

    $FFA2_(16) = 15 \cdot 16^3 + 15 \cdot 16^2 + 10 \cdot 16^1 + 2 \cdot 16^0 =61440 + 3840 + 160 + 2 = 65442_(10)$

    Rules for converting numbers from the decimal number system to another

    • To convert a number from the decimal number system to the binary system, it must be sequentially divided by $2$ until there is a remainder less than or equal to $1$. Represent a number in the binary system as a sequence last result division and remainders from division in reverse order.

    Example 4

    Convert the number $22_(10)$ to the binary number system.

    Solution:

    Figure 4.

    $22_{10} = 10110_2$

    • To convert a number from the decimal number system to octal, it must be sequentially divided by $8$ until there is a remainder less than or equal to $7$. A number in the octal number system is represented as a sequence of digits of the last division result and the remainders from the division in reverse order.

    Example 5

    Convert the number $571_(10)$ to the octal number system.

    Solution:

    Figure 5.

    $571_{10} = 1073_8$

    • To convert a number from the decimal number system to the hexadecimal system, it must be successively divided by $16$ until there is a remainder less than or equal to $15$. A number in the hexadecimal system is represented as a sequence of digits of the last division result and the remainder of the division in reverse order.

    Example 6

    Convert the number $7467_(10)$ to hexadecimal number system.

    Solution:

    Figure 6.

    $7467_(10) = 1D2B_(16)$

      In order to convert a proper fraction from a decimal number system to a non-decimal number system, it is necessary to sequentially multiply the fractional part of the number being converted by the base of the system to which it needs to be converted. Fractions in the new system will be represented as whole parts of products, starting with the first.

      For example: $0.3125_((10))$ in octal number system will look like $0.24_((8))$.

      In this case, you may encounter a problem when a finite decimal fraction can correspond to an infinite (periodic) fraction in the non-decimal number system. In this case, the number of digits in the fraction represented in the new system will depend on the required accuracy. It should also be noted that integers remain integers, but proper fractions- fractions in any number system.

    Rules for converting numbers from a binary number system to another

    • To convert a number from the binary number system to octal, it must be divided into triads (triples of digits), starting with the least significant digit, if necessary, adding zeros to the leading triad, then replace each triad with the corresponding octal digit according to Table 4.

    Figure 7. Table 4

    Example 7

    Convert the number $1001011_2$ to the octal number system.

    Solution. Using Table 4, we convert the number from the binary number system to octal:

    $001 001 011_2 = 113_8$

    • To convert a number from the binary number system to hexadecimal, it should be divided into tetrads (four digits), starting with the least significant digit, if necessary, adding zeros to the most significant tetrad, then replace each tetrad with the corresponding octal digit according to Table 4.