The calculation of computer numbers is binary, but will different encodings generate different binary

Source: Internet
Author: User
For example, the calculation of 2*3 computing opportunity first turns into binary calculation, if it is different encoding form, is not corresponding to the different binary

Reply content:

For example, the calculation of 2*3 computing opportunity first turns into binary calculation, if it is different encoding form, is not corresponding to the different binary

Yes, different codes will have different ways of recording data, and of course they will have similar places.
Coding is mainly for the string, in the digital storage is also the size of the end of the order of the points, are different binary data record rule embodiment.

The master has several basic concepts to figure out first.

The first thing you should say is "2*3" in the source code, the character encoding of the source code files can be different, and their binary representations are different. Then you refer to the "calculation", it must be compiled to generate the target code to be executed (whether it is interpreted or CPU instruction execution), if you are generated machine code, then on the same machine, the digital storage format is the same. If it is the bytecode of a virtual machine that is generated, the number format is the same as the bytecode encoding.

You have to figure out the type of data first. You calculate 2*3 is a two integer calculation, that is, 10*11 (binary), and there is no encoding, you put on a different schema simply means that the length of the integer is different.

You say that the encoding is for characters, such as 2 and 3 ASCII is 0110010 and 0110011 respectively, which is not used to calculate.

Yes, use whatever code you want, and store it anyway.
However, you must ensure that the results are identical.

  • Related Article

    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.