Analysis of the difference between CInt and CLng in ASP _ Application techniques

Source: Internet
Author: User
Tags abs

CInt and clng meaning:

Can force an expression to be converted to a data type

CInt and clng The scope of processing data:

CInt integer-32,768 to 32,767, fractional part rounded.
CLng long-2,147,483,648 to 2,147,483,647, fractional part rounded.

The so-called overflow refers to the scope of processing data, the following code is to handle data to prevent overflow code, you can see for yourselves:

' Detect if it is a short integer

Copy Code code 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 (string,4) >3276 and CInt (right (string,1)) >7 then "Data Overflow": Response.Write
Else
If CInt (Left (ABS (String), 4)) >3276 and CInt (right (string,1) >8 then "Data Overflow": Response.Write
End If
End Sub

' Detect if it is a long integer

Copy Code code 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 (string,9) >214748364 and CLng (right (string,1)) >7 then "Data Overflow": Response.Write
Else
If CLng (Left (ABS (String), 9)) >21478364 and CLng (right (string,1) >8 then "Data Overflow": Response.Write
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.