原文:
http://hail812.blog.163.com/blog/static/174581211201212292515749/
<script type="text/javascript">
function f1(type,num1)
{
switch(type)
{
case ‘floor‘:
return Math.floor(num1);//取整或下舍入
break;
case ‘round‘:
return Math.round(num1);//四舍五入
break;
case ‘ceil‘:
return Math.ceil(num1);//上舍入
break;
case ‘abs‘:
return Math.abs(num1);//取绝对值
break;
}
}
function f2(type,num1,num2,num3)
{
if(type == ‘max‘){
return Math.max(num1,num2,num3);//返回两个值中最大数
}else if(type == ‘min‘){
return Math.min(num1,num2,num3);//返回两个值中最小数
}
}
</script>
时间: 2024-10-25 08:49:16