Python-floating point number integer

Source: Internet
Author: User

There are several methods with different effects.

  1. Type factory function, INT (), effect: the floating point number is rounded up, for example, INT (3.5), 3 is returned; the Character Form of a number is converted to a number, such as int ("35 ") returns 35
  2. The round () of the built-in function is rounded to the fifth place. The second parameter indicates the number of digits after the decimal point. The default value is 0. For example, if round (3.5) returns 4.0, round (3.5, 1) 3.5 is returned and cannot be rounded up... Bytes
  3. The floor () of the math module is an integer smaller than or equal to. For example, floor (3.5) returns 3.0, floor (-1.5) returns-2.0, and cannot be rounded up... Retry

Corresponding to method 1 is the floating point type factory function, float (), for example, float (3) returns 3.0, float ("3.5") returns 3.5

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