javascript整除实现代码


复制代码 代码如下:

//整除
function Div(exp1, exp2)
{
var n1 = Math.round(exp1); //四舍五入
var n2 = Math.round(exp2); //四舍五入
var rslt = n1 / n2; //除
if (rslt >= 0)
{
rslt = Math.floor(rslt); //返回值为小于等于其数值参数的最大整数值。
}
else
{
rslt = Math.ceil(rslt); //返回值为大于等于其数字参数的最小整数。
}
return rslt;
}

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3