javascript float problem

<script language=javascript>
function ceil(number,significance){
if(significance){
return Math.ceil(number/significance) * significance;
}
return Math.ceil(number);
}
document.write(ceil((2025.4/(2000+2*19.05-12.7)).toFixed(3),1));
document.write("<br/>");
document.write(ceil(2.98,2));
</script>

note:  ceil((2025.4/(2000+2*19.05-12.7)),1) = 2, because of float problem, toFixed(prec) fix the problem.

你可能感兴趣的:(javascript float problem)