int函数四舍五入保留两位小数的函数
发布网友
发布时间:2022-04-29 16:14
我来回答
共1个回答
热心网友
时间:2023-10-18 16:37
<script language="javascript">
function roundFun(numberRound,roundDigit) //四舍五入,保留位数为roundDigit ,供计算时用
{
if (numberRound>=0)
{
var tempNumber = parseInt((numberRound * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return tempNumber;
}
else
{
numberRound1=-numberRound
var tempNumber = parseInt((numberRound1 * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return -tempNumber;
}
}
</script>
热心网友
时间:2023-10-18 16:37
<script language="javascript">
function roundFun(numberRound,roundDigit) //四舍五入,保留位数为roundDigit ,供计算时用
{
if (numberRound>=0)
{
var tempNumber = parseInt((numberRound * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return tempNumber;
}
else
{
numberRound1=-numberRound
var tempNumber = parseInt((numberRound1 * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return -tempNumber;
}
}
</script>
热心网友
时间:2023-10-18 16:37
<script language="javascript">
function roundFun(numberRound,roundDigit) //四舍五入,保留位数为roundDigit ,供计算时用
{
if (numberRound>=0)
{
var tempNumber = parseInt((numberRound * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return tempNumber;
}
else
{
numberRound1=-numberRound
var tempNumber = parseInt((numberRound1 * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return -tempNumber;
}
}
</script>
热心网友
时间:2023-10-18 16:37
<script language="javascript">
function roundFun(numberRound,roundDigit) //四舍五入,保留位数为roundDigit ,供计算时用
{
if (numberRound>=0)
{
var tempNumber = parseInt((numberRound * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return tempNumber;
}
else
{
numberRound1=-numberRound
var tempNumber = parseInt((numberRound1 * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
return -tempNumber;
}
}
</script>