asp中的几个取整函数fix(),int(),round()的用法asp
asp中的几个取整函数是:fix(),int(),round();
Int(number)、Fix(number)函数返回数字的整数部分。number 参数可以是任意有效的数值表达式。如果 number 参数包含 Null,则返回 Null。
例:
response.write int(2...
asp中的几个取整函数是:fix(),int(),round();
Int(number)、Fix(number)函数返回数字的整数部分。number 参数可以是任意有效的数值表达式。如果 number 参数包含 Null,则返回 Null。
例:
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函数都删除number参数的小数部分并返回以整数表示的结果。Int和Fix函数的区别在于如果number参数为负数时,Int函数返回小于或等于number的第一个负整数,而 Fix 函数返回大于或等于number参数的第一个负整数。例如,Int将-8.4转换为-9,而 Fix函数将-8.4转换为-8。
round(Expression[, numdecimalplaces])返回按指定位数进行四舍五入的数值。Expression是必选项。数值表达式 被四舍五入。Numdecimalplaces是可选项。数字表明小数点右边有多少位进行四舍五入。如果省略,则Round函数返回整数。
在这里举几个例子:
response.write round(3.14) '3
response.write round(3.55) '4
response.write round(3.1415,3) ' 3.142
Int(number)、Fix(number)函数返回数字的整数部分。number 参数可以是任意有效的数值表达式。如果 number 参数包含 Null,则返回 Null。
例:
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函数都删除number参数的小数部分并返回以整数表示的结果。Int和Fix函数的区别在于如果number参数为负数时,Int函数返回小于或等于number的第一个负整数,而 Fix 函数返回大于或等于number参数的第一个负整数。例如,Int将-8.4转换为-9,而 Fix函数将-8.4转换为-8。
round(Expression[, numdecimalplaces])返回按指定位数进行四舍五入的数值。Expression是必选项。数值表达式 被四舍五入。Numdecimalplaces是可选项。数字表明小数点右边有多少位进行四舍五入。如果省略,则Round函数返回整数。
在这里举几个例子:
response.write round(3.14) '3
response.write round(3.55) '4
response.write round(3.1415,3) ' 3.142
上一篇:ASP保存远程图片文件到本地代码
下一篇:asp自定义函数,带案例使用方法
我要评论