Python standard library: Built-in function float ([x])

Source: Internet
Author: User

This function is to convert a string or an integer to a floating-point number. If the parameterxis a string, the number string is used only in decimal notation, which can be preceded by a symbol to represent a positive number, or negative. If the parameterxis an integer that can be converted to a floating-point number representation. However, there is a special place for this function, which is to useInfinityorinfto represent an infinite number. Like+infis a positive infinity,-infis negative infinity. Here we introduce the infinite concept of mathematics, then infinity multiplied by0is equal to what? Here is equal tonan, i.e.Not a number (is not a number).

Example:

#float () Print (float (' 37.21 ')) print (float (234)) Print (float (' +inf ') + 200000) print (float ('-inf ') * 0) print (float (' C5/>-12345\n ') Print (float (' 1e-003 '))

The output results are as follows:

37.21

234.0

Inf

Nan

-12345.0

0.001


Cai Junsheng qq:9073204 Shenzhen

Python standard library: Built-in function float ([x])

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.