搜索

JS:Math.ceil(),Math.floor()与Math.round()

0620

JavaScript: The Definitive Guide, 4th Edition中对Math.ceil(),Math.floor()与Math.round()三个函数的定义。


document.writeln("Math.ceil(4.8992303)输出结果:"+Math.ceil(4.8992303)+"<br/>");
document.writeln("Math.floor(4.8992303)输出结果:"+Math.floor(4.8992303)+"<br/>");
document.writeln("Math.round(4.8992303)输出结果:"+Math.round(4.8992303)+"<br/><br/>");
document.writeln("Math.ceil(4.29993354)输出结果:"+Math.ceil(4.29993354)+"<br/>");
document.writeln("Math.floor(4.29993354)输出结果:"+Math.floor(4.29993354)+"<br/>");
document.writeln("Math.round(4.29993354)输出结果:"+Math.round(4.29993354));

继续阅读»