欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP(VBScript)中整除和取余

 更新時(shí)間:2014年12月08日 17:29:33   投稿:mdxy-dxy  
這篇文章主要介紹了ASP(VBScript)中整除和取余方法,需要的朋友可以參考下

整除

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 子類(lèi)型表達(dá)式。Long 子類(lèi)型的范圍是 [-2147483648, 2147483647],也就是說(shuō),要進(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

測(cè)試代碼:

<%
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>"
%>

相關(guān)文章

最新評(píng)論