国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

asp cint clng的范圍與防止cint和clng的溢出解決方法大全

2024-05-04 10:57:38
字體:
來源:轉載
供稿:網友

首先我們需要了解的是

cint范圍 -32,768 到 32,767。
clng范圍 -2,147,483,648 到 2,147,483,647。

cint與clng含義:

都可以強制將一個表達式轉換成數據類型

cint與clng處理數據的范圍:

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

所謂溢出指的是超出處理數據的范圍,下面代碼是處理數據防止溢出的代碼,大家可以自己看看:

'檢測是否是短整數

復制代碼 代碼如下:

sub Is_Int(string)
if len(abs(string))>10 then response.write "數據溢出":response.end
if instr(string,"-")<1 then
if cint(left(string,4))>3276 and cint(right(string,1))>7 then response.write "數據溢出":response.end
else
if cint(left(abs(string),4))>3276 and cint(right(string,1))>8 then response.write "數據溢出":response.end
end if
end sub


'檢測是否是長整數
復制代碼 代碼如下:

sub Is_Lng(string)
if len(abs(string))>10 then response.write "數據溢出":response.end
if instr(string,"-")<1 then
if clng(left(string,9))>214748364 and clng(right(string,1))>7 then response.write "數據溢出":response.end
else
if clng(left(abs(string),9))>21478364 and clng(right(string,1))>8 then response.write "數據溢出":response.end
end if
end sub


以下是一些檢驗函數,需要的朋友可以參考下:

第一種:
一、檢測它是不是整數 
復制代碼 代碼如下:

function Is_Int(a_str)  
   if not isnumeric(a_str) or len(str) > 5 then  
      Is_Int = false   
      exit function   
   elseif len(str) < 5 then  
      Is_Int = true   
      exit function   
   end if     
   if cint(left(a_str , 4)) > 3276 then  
      Is_Int = false  
      exit function  
   elseif cint(left(a_str , 4)) = 3276 and cint(right(a_str , 1)) > 7 then  
      Is_Int = false  
      exit function  
   else  
      Is_Int = true  
      exit function  
   end if     
end function  
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 略阳县| 五华县| 通州区| 金寨县| 哈巴河县| 湘乡市| 承德市| 东兴市| 广昌县| 武宁县| 昭通市| 吉木乃县| 周至县| 岚皋县| 金溪县| 祁门县| 沈阳市| 东海县| 平度市| 云南省| 启东市| 沐川县| 宿迁市| 桐乡市| 宁化县| 普兰店市| 绥阳县| 安康市| 济阳县| 康保县| 梓潼县| 林州市| 垣曲县| 凤山县| 宁武县| 潍坊市| 靖西县| 泰安市| 普定县| 靖安县| 宁武县|