asp中的几个取整函数

 

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值