Fifth Python numbers

Source: Internet
Author: User
5.1 Number types
The numbers provide scalar storage and direct access. It is a non-changeable type, meaning that the value of the change number generates a new object. Of course, this process is transparent to both the programmer and the user, and does not affect how the software is developed. Python supports multiple numeric types: Integer, Long, Boolean, double, decimal, and complex.

How to update a numeric object
Because you don't actually update the original value of the object. This is because numeric objects are immutable objects. The object model of Python is somewhat different from the regular object model. What you think of the update is actually generating a new numeric object and getting a reference to it.
In the process of learning programming, we have been taught that the variable is like a box containing the value of the variable. In Python, a variable is more like a pointer to a box that is loaded with variable values. You can't change the contents of a box for an immutable type, but you can point the pointer to a new box. Each time you assign a different number to a variable, you actually create a new object and assign it to the variable. (not just numbers, for all immutable types)
Anint + = 1
Afloat = 2.718281828
How to delete a numeric object
According to Python's law, you can't really delete a numeric object, you just don't use it anymore. If you
Actually want to delete a reference to a numeric object, use the DEL statement (see 3.5.6). To delete a reference to an object
, you can no longer use this reference (the variable name) unless you assign it a new value. If an attempt is made to use a
A Nameerror exception is thrown when an object reference is deleted.
Del Anint
Del along, afloat, Acomplex

5.3 Double-precision floating-point numbers
Floating-point numbers in Python are similar to the double type in the C language, and are two-precision floating-point numbers that can be represented by a direct decimal or scientific notation. Each floating-point number occupies 8 bytes (64 bits), fully complies with the IEEE754 number specification (52M/11E/1S), where 52 bits are used to represent the bottom, 11 bits are used to represent the exponent (which can represent a range of approximately 10 of a plus or minus 308.25), and the remaining bit represents the symbol. This looks quite perfect, however, the actual accuracy depends on the machine architecture and the compiler that created the Python interpreter. Floating-point values usually have a decimal point and an optional suffix e (uppercase or lowercase, which indicates scientific notation). The positive (+) or negative (-) can be used between the E and the exponent to indicate the positive and negative of the exponent (a positive word can omit the symbol). Here are some examples of typical floating-point values:
0.0-777. 1.6-5.555567119 96e3 * 1.0
4.3e25 9.384e-23-2.172818 Float (12) 1.000000001
3.1416 4.2e-10-90. 6.022e23-1.609e-19

5.4 plural

Here are a few concepts about complex numbers in the Python language:

  • 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.