The difference between CInt and int in ASP _ Application techniques

Source: Internet
Author: User

The CInt is rounded to the nearest even number, which means that when the decimal part is 0.5XXXX, it takes the nearest even to the x.5xx.

such as Cint (0.5) =0; Cint (1.5) =2; Cint (2.5) =2; Cint (3.5) =4

An int is an integer function that removes the decimal point part. such as int (1.5) =1 ...

This positioning is not accurate, according to the test of the angle is leakage. First: The Cint function does not take into account the situation of Cint (0.51) =1,cint (2.51) =3. The second: The INT function does not take into account the case of negative numbers: Int ( -1.1) =-2,int (-1.5) =-2, so I conclude as follows: Int function: On the axis to the left rounding. CInt function: Rounded rounding, regardless of positive or negative values.          However, when *.5 or-*.5, the number is taken as a couple. But note: Cint (0.51) =1,cint (-0.51) is equal to 1.

Summarize:

int function: To the left rounding on a axis.

CInt function: Rounded rounding, regardless of positive or negative values. However, when *.5 or-*.5, the number is taken as a couple.

Cint (0.5) =0-> 0
Cint (0.51) =1-> 1
Cint (1.5) =2-> 2
Cint (2.5) =2-> 2
Cint (2.51) =3-> 3
Cint (2.6) =3-> 3
Cint (2.62) =3-> 3
Cint (3.5) =4-> 4
Cint (3.3) =3-> 3
Cint (1.2) =1-> 1
Int ( -1.1) =-2->-2
Int ( -1.5) =-2->-2

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.