Brain complement "mathematical binary to Decimal"

Source: Internet
Author: User
Tags binary to decimal

Reproduced in original: http://jingyan.baidu.com/article/597a0643614568312b5243c0.html

  • into the binary system mainly have the following: positive integer to binary, negative integer to binary, fractional to binary;
    1. The positive integer turns into binary. Points must be sure to remember Kazakhstan: In addition to the second, and then the reverse order, high 0.
    That is, the positive decimal number divided by two, the quotient is divided by two, and so on to know that the quotient is zero or one o'clock, and then mark the remainder of each step, and finally write it backwards, high 0 is OK. Alas, let's say, for example, that 42 is converted to binary, 1 as shown.


    42 divided by 2 to get the remainder is 010101, and then we row backwards, 42 corresponds to the binary is 101010.2 is shown more intuitive expression.

    The number of bytes in a computer's internal representation is fixed-length, such as 8-bit, 16-bit, or 32-bit. So, when the number of digits is not enough, the high 0, said, 3, 42 is converted to binary after the. 00101010, that is, the specification of the notation is (42) 10 = (00101010) 2. Remember it.

    2. Convert negative integers into binary
    Method: First convert the corresponding positive integer into binary, reverse the binary, and then add one to the result. Also take 42 as an example, the negative integer is -42,4 is shown as the method explanation. The last is: (-42) 10 = (11010110) 2.

    3, decimal conversion to binary method: the number after the decimal point multiplied by 2, there is a result bar, take the integer part of the result (not 1 is 0), and then the fractional part is multiplied by 2, then the result of the integer part ... And so on, until the number is divided into 0 or the number of digits is enough, OK. Then the whole number is sorted in order, which makes up the binary fractional part sequence, for example, 0.125, 5.

    What if the integer part of the decimal has an integer greater than 0? As the above integers are converted to binary, the decimal is converted to binary, and then added together is OK, as shown in 6.

    4, the integer binary conversion to decimal: First, the binary number of bits, the first if 0 is a positive integer, if the first is 1 is a negative integer.
    First, the first is a positive integer of 0, after the number of bits, the number of bits in the binary will be multiplied by the corresponding value, and then added to the decimal, for example, 1010 is converted to decimal, Method 7 is shown.

    5, if the second complement of the number of digits after the first is 1 o'clock, you need to take the reverse conversion: for example, 11101011, the first is 1, then first take the reverse bar:-00010100, and then calculate the 10100 corresponding to the decimal 20, so the corresponding decimal 20, method 8 is shown.

    6. When converting decimal binary to decimal: for example, 0.1101 is converted to decimal method: The value that is added after multiplying the four-digit number in the binary by the corresponding value below (9) is the converted decimal.

Brain complement "mathematical binary to Decimal"

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.