加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

asp中cint与clng的区别分析

发布时间:2016-12-07 19:49:14 所属栏目:PHP教程 来源:网络整理
导读:cint与clng含义: 都可以强制将一个表达式转换成数据类型 cint与clng处理数据的范围: CIntnbsp;nbsp;nbsp; Integernbsp;nbsp;nbsp;nbsp;nbsp;nbsp; -32,768 至 32,767,小数部分四舍五入。 CLngnbsp;nbsp;nbsp; Longnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;n

cint与clng含义:

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

cint与clng处理数据的范围:

CIntnbsp;nbsp;nbsp; Integernbsp;nbsp;nbsp;nbsp;nbsp;nbsp; -32,768 至 32,767,小数部分四舍五入。
CLngnbsp;nbsp;nbsp; Longnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; -2,147,483,648 至 2,147,483,647,小数部分四舍五入。

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

'检测是否是短整数
复制代码 代码如下:
sub Is_Int(string)
if len(abs(string))gt;10 then response.write "数据溢出":response.end
if instr(string,"-")lt;1 then
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; if cint(left(string,4))gt;3276 and cint(right(string,1))gt;7 then response.write "数据溢出":response.end
nbsp;nbsp;nbsp; else
nbsp;nbsp;nbsp;nbsp;nbsp; if cint(left(abs(string),4))gt;3276 and cint(right(string,1))gt;8 then response.write "数据溢出":response.end
nbsp;nbsp; end if
end sub

'检测是否是长整数
复制代码 代码如下:
sub Is_Lng(string)
if len(abs(string))gt;10 then response.write "数据溢出":response.end
if instr(string,"-")lt;1 then
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; if clng(left(string,9))gt;214748364 and clng(right(string,1))gt;7 then response.write "数据溢出":response.end
nbsp;nbsp;nbsp; else
nbsp;nbsp;nbsp;nbsp;nbsp; if clng(left(abs(string),9))gt;21478364 and clng(right(string,1))gt;8 then response.write "数据溢出":response.end
nbsp;nbsp; end if
end sub

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读