How do I convert decimal to binary?

Updated on technology 2024-04-09
9 answers
  1. Anonymous users2024-02-07

    #include

    using namespace std;

    struct stack

    int * num;

    int top;

    void init_stack(stack &stack)int[100];

    delete ;

    void push(stack &stack,int n);

    int is_empty(stack &stack)return ? 1:0;

    void pop(stack &stack)if(!is_empty(stack))

    void f(int n)

    if(n==0)

    cout<<"The decimal number is:"<>n;

    f(n);return 0;

    Stack implementation, to give points!!

  2. Anonymous users2024-02-06

    Formula: Integer binary is multiplied by the power of 2, and decimal binary is multiplied by the negative power of 2 and then added in turn.

    1. Convert integer binary to decimal system: first complete the binary number with digits, if the first digit is 0, it means that it is a positive integer, and if the first digit is 1, it means that it is a negative integer.

    If the first digit after the binary is full of digits, as shown in the figure below, you need to take the negation first and then convert:

    2. Convert the binary of decimals to decimal system: The value obtained by multiplying the corresponding values of the four decimal places in the binary system (as shown in the figure below) is the converted decimal system.

  3. Anonymous users2024-02-05

    Decimal numbers, individual digits, respectively: .Thousand, hundred, ten, one .

    Binary numbers, individual digits, respectively: .Eight, four, two, one...

    The rest of the bits, it's up to you, and you'll be slowly groping.

    The decimal number, 8031, is: 8 thousand, 0 hundred, 3 ten, 1.

    The binary number, 1101, is: 1 eight, 1 four, 0 two, 1 one, i.e. 13 in decimal.

  4. Anonymous users2024-02-04

    Convert decimal decimal to binary decimal adopt"Multiply by 2 and round up, in order"Law. For example, here's how:

    1. Integer operation.

    1. Multiply 2 by decimal decimal places to get the product: 2*;

    2. Take out the integer part of the product 1, and then multiply the remaining decimal part by 2 to get another product, then 2*

    3. Then take out the integer part of the product, and so on, then; At this point, the decimal part of the product is zero, and 0 or 1 is the last digit of binary and is no longer counted down.

    2. Sort it out.

    Arrange the integer parts in order, with the integer taken first as the high significant digit of the binary decimal place, and the integer taken later as the low significant digit. Namely.

  5. Anonymous users2024-02-03

    1. Integer binary conversion.

    is decimal. Method: Start by adding binary numbers.

    Fill up the digits, if the first digit is 0, it means that it is a positive integer.

    If the first digit is 1, it means a negative integer.

    If the first digit is a positive integer of 0, after completing the number of digits, multiply the digits in the binary by the corresponding values, and then add them to get the decimal system.

    If the first digit after the binary is full of digits, it needs to be reversed first and then converted.

    2. Convert decimal binary to decimal system.

    Method: Multiply the number of digits in binary by the corresponding value, and then add them together, and the resulting value is the converted decimal system.

  6. Anonymous users2024-02-02

    It is known that the decimal number, the individual digits are: .Thousand, hundred, ten, one .

    Similar, binary numbers, each bit is: .Eight, four, two, one...

    The rest of the bits, it's up to you, and you'll be slowly groping.

    The decimal number, 8031, is: 8 thousand, 0 hundred, 3 ten, 1.

    The binary number, 1101, is: 1 eight, 1 four, 0 two, 1 one. i.e. 13 in decimal.

  7. Anonymous users2024-02-01

    How it works:

    Binary to decimal :

    Converting binary to decimal is relatively simple, as long as you follow the rules. Binary numbers are marked with a footmark of 2 in the lower right corner of the number, and the same is true for decimal numbers plus 10. The rules are as follows:

    Convert decimal to binary one integer conversion:

    The conversion of decimal integers to binary can be obtained in a form similar to division, and the quotient obtained each time is repeatedly divided by 2 to find each bit of the binary number. The form is as follows:

    Decimal to binary decimal conversion:

    The decimal part is repeatedly multiplied by 2 to 2, and the integer part of the resulting number is 1, then the corresponding bit is 1, and the obtained integer part is 0, then the corresponding bit is 1. The form is as follows:

    Convert the integer part and the decimal part of a number into binary numbers, and then merge the binary numbers of the two parts to get a complete binary number. First of all, through short division, let the decimal number be continuously divisible by 2, you can get multiple remainders, and finally arrange and combine the obtained remainders from bottom to top to get the converted binary number.

    Note that when converting decimal to binary, integers and decimal are converted differently. , note the direction in which the conversion is written.

    Hope it helps you, or you adopt it in time thank you!

  8. Anonymous users2024-01-31

    Conversion methods between various base systems:

    1. Conversion of different carry numbers into decimal numbers: add them by weight.

    The decimal system is weighted to 10; Binary is the right is 2; Hexadecimal is weighted to 16; The octal is that the weight is 8;

    Example: 110011 (binary number) = 1*2 5+1*2 4+0*2 3+0*2 2+1*2 1+1*2 0=32+16+2+1=51

    1507 (octal number) = 1*8 3 + 5*8 2 + 0*8 1 + 7*8 0 = 839

    2af5 (hexadecimal number) = 2*16 3 + a*16 2+ f*16 1 + 5*16 0 = 10997

    2. Convert decimal numbers into decimal numbers.

    Integer part: dividing the balance; Decimals: Multiplied to round up.

    Example: Convert a decimal number 13 to a binary number.

    13 2=6 remainder 1

    6 2=3 0

    3 2=1 remainder 1

    1 2=0 remainder 1

    Results: 1101

    3. Binary to octal.

    Turning binary numbers from right to left, in groups of three, is not enough to make up 0

    Example: Binary numbers 10110111011 to octal numbers:

    The result is: 2673

    Fourth, binary to hexadecimal.

    The method of converting binary numbers to hexadecimal numbers is similar, from right to left, in a group of four digits, which is not enough to make up 0 as above

    The result is: 5bb as above:

    The result is: 5bb

  9. Anonymous users2024-01-30

    1. Conversion between decimal and binary (1) Decimal is converted to binary, divided into integer part and decimal part Integer part method: divide by 2 remainder, that is, divide the integer part by 2 each time, the remainder is the number on the bit weight, and the quotient continues to divide by 2, and the remainder is the number on the previous bit weight, this step continues until the quotient is 0, and the last reading, starting from the last remainder reading, all the way to the first remainder. Here's an example:

    Example: Convert 168 in decimal to binary to get the result Convert 168 in decimal to binary, (10101000) 2 Analysis: In the first step, divide 168 by 2, quotient 84, and the remainder is 0.

    In the second step, divide quotient 84 by 2, and the remainder of quotient 42 is 0. In the third step, divide quotient 42 by 2, and the remainder of quotient 21 is 0. In the fourth step, divide quotient 21 by 2, and the remainder of quotient 10 is 1.

    In the fifth step, divide quotient 10 by 2, and the remainder of quotient 5 is 0. In the sixth step, divide quotient 5 by 2, and the remainder of quotient 2 is 1. In the seventh step, divide quotient 2 by 2, and the remainder of quotient 1 is 0.

    In the eighth step, divide quotient 1 by 2, and the remainder of quotient 0 is 1. The ninth step, reading, because the last digit is obtained after dividing by 2 many times, so it is the highest digit, and the reading digit is read forward from the last remainder, that is, 10101000 (2) Decimal part method: multiply by 2 to take the whole number, that is, multiply the decimal part by 2, then take the integer part, the remaining decimal part continues to multiply by 2, then take the integer part, and multiply the remaining decimal part by 2, until the decimal part is zero.

    If it can never be zero, just like rounding decimal numbers, when retaining how many decimal places are required, choose according to whether the next digit is 0 or 1, if it is zero, round off, if it is 1, enter one place. In other words, 0 rounding. The reading should be read from the first integer to the next integer, as shown below

    Example 1: Convert to binary to get the result: Convert to binary (analysis:

    The first step is to multiply by 2 to obtain, then the integer part is 0 and the decimal part is; The second step is to multiply the decimal part by 2 to get it, then the integer part is 0, and the decimal part is; The third step is to multiply the decimal part by 2 to obtain, then the integer part is 1 and the decimal part is; The fourth step, reading, starts from the first reading and reads to the last digit, that is. The method of converting decimal to binary, you need to pay attention to: 1) Decimal to binary, you need to divide into two parts, integer and decimal number, respectively2) When converting integer, use the remainder method of dividing by 2, and when converting decimals, use multiply by 2 to take the whole number3) Pay attention to the direction of their readingTherefore, from the above method, we can conclude that the decimal number is converted to binary as, or the decimal number is converted to binary number approximately equal.

    3) Binary to Decimal The method of not dividing integers and decimal parts: add by weight, that is, multiply the number on each bit of binary by the weight, and then add it to the sum of the decimal numbers. Example: Converting binary numbers to decimal numbers.

Related questions
8 answers2024-04-09

Convert decimal integers to binary numbers.

The divide by 2 reverse remainder method is adopted: >>>More

10 answers2024-04-09

If it's a method, I can give you a natural language description of how the decimal integer part n can be converted to binary as follows: >>>More

8 answers2024-04-09

First of all, you need to convert the number into two parts: an integer and a decimal. Integer part: divide by two and take the remainder inverted: >>>More

8 answers2024-04-09

1.Binary 1000 is replaced by 16.

With the 8421 conversion method, that is, from left to right, 8*1+4*0+2*0+1*0=0x8, this is the universal conversion method for all hexadecimal to binary, bit-to-bit alignment conversion, multiply by 8421 respectively, and then add up. If the binary number. >>>More

13 answers2024-04-09

Because I don't know which microcontroller this is and the specific assembly syntax it corresponds to, but the basic idea is: >>>More