binary conversion, character encoding evolution, encoding used in Python, floating-point numbers, accuracy of floating-point numbers

Source: Internet
Author: User
Tags decimal to binary

Binary Conversions

Binary is a kind of system widely used in computing . The binary number is the number represented by 0 and 12 digits. Its base is 2, the rounding rule is "every two in one", the borrow rule is "borrowing one as two", which was found by the 18th century German mathematical philosophy master Leibniz . The current computer system is basically binary systems , the data in the computer is mainly in the form of complement storage. The binary in the computer is a very small switch, with "on" to indicate 1, "off" to represent 0.

    • In ancient times the enemy came, how to communicate?
① sent people run to inform, speed too slow, and so people come back, battle also finished.
② Point smoke signals signal, how to point it?

You want to have one of them? Came 5000 people, point 5000, do not have to fight, and burned himself to death.

That is agreed, to 10 people point 1, to 100 people point 2, to 1000 people point 3, to 5,000 points 4, to 10,000 points 5 root.

But this is not very accurate, how can be more accurate?

① If there are 20 smoke signals holes, the smoke signals hole is lit to represent someone, not lit on behalf of no one. At this time, 1 enemies came, point 1 smoke signals.

② 2 more enemies? Put the first smoke signals hole out and light the second one, so that only the second hole is lit to represent two people.

③ now 3 enemies? Then the first smoke signals hole is lit, it represents 3 people.

④ If there are 4 enemies, now there are two smoke signals are lit can only represent 3 people, so have to point another, but also to eliminate the front two, because the third root of this smoke signals can represent 4 enemies.

。。。。。。。。。。。。。。。

    • 1,2,4,8,16,32,64: The number of enemies is accurately represented by 2 of the n-th square.

    • binary and decimal conversion small exercise

Let's first write down the values they represent, and then fill in the corresponding position according to the value of the 10 binary.

Decimal to binary binary method is the same, as long as the binary is 1 of the corresponding decimal value is added.

256 128 64 32 16 8 6 4 2

1 0 1 0 1 0 1 1 0 = 342

     
    • Use the Python built-in method-bin (n) Calculation

ASCII code and Binary

    • How does the computer convert text into binary?

    • Corresponding relational table--ascii code table

SCII (American Standard Code for Information Interchange, U.S. Information Interchange standards codes) is a computer-encoded system based on the Latin alphabet, mainly used to display modern English and other Western European languages. It is now the most versatile single-byte encoding system and is equivalent to ISO/IEC 646.

Since the computer was invented by the Americans, only 127 letters were encoded into the computer, that is, letters, numbers, and symbols, which are called ASCII encodings, such as uppercase letters encoded in A 65 lowercase letters z 122 . The latter 128 are called extended ASCII codes.

    • Text conversion to Binary

        一个空格对应的数字是0          翻译成二进制就是0(注意字符‘0‘和整数0是不同的)        一个对勾√对应的数字是251       翻译成二进制就是11111011

    • In the ASCII code table, the maximum number of characters is 255 bits, so we use 8 bits to represent 1 characters

① each 0 or 1 space unit is bit (bit), which is the "smallest representation unit" in the computer.

②8bit = 1bytes, is the "smallest storage unit" in the computer, and the 1bytes abbreviation is 1 B.

the evolution of character encoding
    • GBK18030 and GB2312 and GBK1.0

    • there are hundreds of languages all over the world, Japan has made Japanese into shift_jis, and Korea has made Korean into Euc-kr . countries have national standards, there will inevitably be conflicts, the result is that in multi-language mixed text, the display will be garbled.

The code used in Python

    • python2.x default encoding is ASCII

python2.x want to change to UTF-8 to add "#!" at the beginning -*-coding:utf-8-*-"

    • python3.x default encoding is UTF-8

Basic data Types

    • Floating point number

    • Scientific counting method

The problem of the accuracy of floating point numbers

    • In Python, floating-point numbers can only store 16 bits accurately.

binary conversion, character encoding evolution, encoding used in Python, floating-point numbers, accuracy of floating-point numbers

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.