Differences between cint and clng in asp

Source: Internet
Author: User

Meaning of cint and clng:

You can forcibly convert an expression to a data type.

Cint and clng:

CInt Integer-32,768 to 32,767, rounded to the decimal part.
CLng Long-2,147,483,648 to 2,147,483,647, rounded to the decimal part.

Overflow refers to a code that is out of the scope of data processing. The following code processes data to prevent data overflow. You can check it for yourself:

'Check whether it is a short integer

Copy codeThe Code is as follows: sub Is_Int (string)
If len (abs (string)> 10 then response. write "Data overflow": response. end
If instr (string, "-") <1 then
If cint (left (string, 4)> 3276 and cint (right (string, 1)> 7 then response. write "Data overflow": response. end
Else
If cint (left (abs (string), 4)> 3276 and cint (right (string, 1)> 8 then response. write "Data overflow": response. end
End if
End sub

'Check whether it is a long integer

Copy codeThe Code is as follows: sub Is_Lng (string)
If len (abs (string)> 10 then response. write "Data overflow": response. end
If instr (string, "-") <1 then
If clng (left (string, 9)> 214748364 and clng (right (string, 1)> 7 then response. write "Data overflow": response. end
Else
If clng (left (abs (string), 9)> 21478364 and clng (right (string, 1)> 8 then response. write "Data overflow": response. end
End if
End sub
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.