cint與clng含義:
都可以強(qiáng)制將一個(gè)表達(dá)式轉(zhuǎn)換成數(shù)據(jù)類型
cint與clng處理數(shù)據(jù)的范圍:
CInt Integer -32,768 至 32,767,小數(shù)部分四舍五入。
CLng Long -2,147,483,648 至 2,147,483,647,小數(shù)部分四舍五入。
所謂溢出指的是超出處理數(shù)據(jù)的范圍,下面代碼是處理數(shù)據(jù)防止溢出的代碼,大家可以自己看看:
'檢測(cè)是否是短整數(shù) sub Is_Int(string) if len(abs(string))>10 then response.write "數(shù)據(jù)溢出":response.end if instr(string,"-")1 then if cint(left(string,4))>3276 and cint(right(string,1))>7 then response.write "數(shù)據(jù)溢出":response.end else if cint(left(abs(string),4))>3276 and cint(right(string,1))>8 then response.write "數(shù)據(jù)溢出":response.end end if end sub
檢測(cè)是否是長(zhǎng)整數(shù)
sub Is_Lng(string) if len(abs(string))>10 then response.write "數(shù)據(jù)溢出":response.end if instr(string,"-")1 then if clng(left(string,9))>214748364 and clng(right(string,1))>7 then response.write "數(shù)據(jù)溢出":response.end else if clng(left(abs(string),9))>21478364 and clng(right(string,1))>8 then response.write "數(shù)據(jù)溢出":response.end end if end sub
具體使用看這個(gè)數(shù)字可能最大區(qū)間,一般分頁可以用cint,文章id用clng比較好。
在我以前做asp開發(fā)時(shí),特別是涉及到商務(wù)類的計(jì)算時(shí),clng用的比較多,cint主要用于處理短整數(shù)。
有了上面的二個(gè)函數(shù),有效防止了溢出,很有用。
標(biāo)簽:南寧 淮北 揭陽 唐山 迪慶 甘南 滁州 來賓
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp中cint與clng的區(qū)別分析》,本文關(guān)鍵詞 asp,中,cint,與,clng,的,區(qū)別,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。