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

首頁 > 編程 > ASP > 正文

ASP(VBScript)中整除和取余

2020-07-27 12:41:19
字體:
供稿:網(wǎng)友

整除

ASP(VBScript) 中整除用“/”,比如 m = 5 / 2,結(jié)果為 2。

取余

ASP(VBScript) 中取余用 mod,比如 m = 5 mod 2,結(jié)果為 1。

大數(shù)注意

m = 4444444444 / 2
n = 4444444444 / 2

第一句是正確的,第二句運(yùn)行時(shí)會(huì)報(bào)溢出錯(cuò)誤,因?yàn)椋涸谡⑷∮嗖僮髑埃瑪?shù)值表達(dá)式四舍五入為 Byte、Integer 或 Long 子類型表達(dá)式。Long 子類型的范圍是 [-2147483648, 2147483647],也就是說,要進(jìn)入整除或取余的數(shù)字必須在這個(gè)范圍內(nèi)。

asp中的幾個(gè)取整函數(shù)

asp中的幾個(gè)取整函數(shù)是:fix(),int(),round();

Int(number)、Fix(number)函數(shù)返回?cái)?shù)字的整數(shù)部分。number 參數(shù)可以是任意有效的數(shù)值表達(dá)式。如果 number 參數(shù)包含 Null,則返回 Null。
例:

復(fù)制代碼 代碼如下:

response.write int(2.14) '2
response.write fix(2.14) '2
response.write int(2.54) '2
response.write int(2.54) '2

    Int 和 Fix 函數(shù)都刪除 number 參數(shù)的小數(shù)部分并返回以整數(shù)表示的結(jié)果。Int 和 Fix 函數(shù)的區(qū)別在于如果 number 參數(shù)為負(fù)數(shù)時(shí),Int 函數(shù)返回小于或等于 number 的第一個(gè)負(fù)整數(shù),而 Fix 函數(shù)返回大于或等于 number 參數(shù)的第一個(gè)負(fù)整數(shù)。例如,Int 將 -8.4 轉(zhuǎn)換為 -9,而 Fix 函數(shù)將 -8.4 轉(zhuǎn)換為 -8。

round(Expression[, numdecimalplaces])返回按指定位數(shù)進(jìn)行四舍五入的數(shù)值。Expression是必選項(xiàng)。數(shù)值表達(dá)式 被四舍五入。Numdecimalplaces是可選項(xiàng)。數(shù)字表明小數(shù)點(diǎn)右邊有多少位進(jìn)行四舍五入。如果省略,則 Round 函數(shù)返回整數(shù)。
例:

復(fù)制代碼 代碼如下:

response.write round(3.14) '3
response.write round(3.55) '4
response.write round(3.1415,3) ' 3.142

測試代碼:

<%response.write 650/100&"<br>"response.write int(650/100)&"<br>"response.write fix(650/100)&"<br>"response.write int(2.54)&"<br>"response.write int(2.54)&"<br>"%>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 商都县| 平利县| 马龙县| 庄河市| 岢岚县| 康定县| 沂南县| 连山| 扎赉特旗| 天祝| 新营市| 怀仁县| 涿鹿县| 双辽市| 清水河县| 慈溪市| 阿荣旗| 嘉禾县| 涡阳县| 图木舒克市| 东城区| 南靖县| 贞丰县| 平泉县| 牙克石市| 大庆市| 柘荣县| 岚皋县| 巫山县| 六枝特区| 凤山市| 通海县| 龙岩市| 北宁市| 方山县| 盖州市| 闽侯县| 兴安盟| 阿克苏市| 苍梧县| 和政县|