Four numeric types (int, long, float, complex) and pythoncomplex

Source: Internet
Author: User

Four numeric types (int, long, float, complex) and pythoncomplex

Python supports four different numeric types, including int (integer) long (long integer) float (floating point actual value) complex (plural ), this article introduces four numeric types of python to coders. For more information, see.

The numeric data type stores the numeric value. They are unchangeable data types, which means changing the numeric data type results in a new assigned object value.

Number object is created when you assign a value to them. For example:

var1 = 1var2 = 10

You can also delete the numeric object reference by using the del statement.

The syntax of the del statement is:

del var1[,var2[,var3[....,varN]]]]

You can use the del statement to delete a single object or multiple objects.

For example:

del vardel var_a, var_b

Python supports four different numeric types:

• Int (symbol integer ):It is usually called an integer or integer, and there is no positive or negative integer of the decimal point.

• Long (long integer ):Or a desire, an integer of infinite size, which is written into an integer and an L in upper or lower case.

• Float (actual floating point value ):The color car represents the real number, the decimal part divided by the integer part and the decimal part in writing. Floats may also be in scientific notation with E or Directive 10th power é (2.5e2 = 2.5 × 102 = 250 ).

• Complex (plural ):+ BJ form, where a and B are the square root of-1 represented by cars and J (or J) (this is a virtual number ). A is the real numeric part, and B is the virtual part. Do not use Python programming for plural numbers.

Here are some examples of numbers:

Int Long Float Complex
10 51924361L 0.0 3.14j
100 -0x19323L 15.20 45. j
-786 0122L -21.9 9.322e-36j
080 0 xDEFABCECBDAECBFBAEl 32.3 + e18 . 876j
-0490 535633629843L -90. -. 6545 + 0J
-0x260 -052318172735L -32.54e100 3e + 26J
0x69 -4721885298529L 70.2-E12 4.53e-7j

• Python allows you to use lowercase letters of L, but we recommend that you use only one uppercase letter of L to avoid confusion with number 1. The python long integer displays an uppercase letter (L.

• An ordered complex number is composed of a real floating point number + BJ, where a is the real part and B is the imaginary part of the plural.

Numeric type conversion:

The numeric conversion in Python contains a common mixed expression of rating types. But sometimes you need to explicitly force a number from one type to another operator or function parameters to meet the requirements.

• Int type (X) converts X to a common integer.

• Long (X) converts X to a long integer.

• Float type (X) converts X to a floating point number.

• Complex (x) converts X to a complex number from x to zero in Part x and imaginary. Complex types (X, Y) convert the nth and imaginary verbs of x and y. X and y are numeric expressions with the built-in number function:

The above discussion about the four numeric types of python (int, long, float, complex) is all the content that I have shared with you. I hope you can give me a reference, we also hope that you can support the customer's home.

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.