zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

asp中cint与clng的区别分析

ASP 分析 区别
2023-06-13 09:14:48 时间

cint与clng含义:

都可以强制将一个表达式转换成数据类型

cint与clng处理数据的范围:

CInt   Integer      -32,768至32,767,小数部分四舍五入。
CLng   Long        -2,147,483,648至2,147,483,647,小数部分四舍五入。

所谓溢出指的是超出处理数据的范围,下面代码是处理数据防止溢出的代码,大家可以自己看看:

"检测是否是短整数

复制代码代码如下:

subIs_Int(string)
iflen(abs(string))>10thenresponse.write"数据溢出":response.end
ifinstr(string,"-")<1then
      ifcint(left(string,4))>3276andcint(right(string,1))>7thenresponse.write"数据溢出":response.end
   else
     ifcint(left(abs(string),4))>3276andcint(right(string,1))>8thenresponse.write"数据溢出":response.end
  endif
endsub

"检测是否是长整数

复制代码代码如下:

subIs_Lng(string)
iflen(abs(string))>10thenresponse.write"数据溢出":response.end
ifinstr(string,"-")<1then
      ifclng(left(string,9))>214748364andclng(right(string,1))>7thenresponse.write"数据溢出":response.end
   else
     ifclng(left(abs(string),9))>21478364andclng(right(string,1))>8thenresponse.write"数据溢出":response.end
  endif
endsub