Javascript数学舍入
  可能重复: 
  JavaScript的数学是否被破坏? 
好的,我有这个脚本:
var x = new Date;
setInterval(function() {
    $("#s").text((new Date - x) / 60000 + "Minutes Wasted");
}, 30000);
  它工作得很好。  除了它有时会给我一个像4.000016666666666的答案。  我怎么能这样做?  如果我必须重写脚本,那没关系。  谢谢! 
您可以使用Math.floor()函数“向下舍入”
$("#s").text(Math.floor((new Date - x) / 60000 + "Minutes Wasted"));
或Math.ceil(),其中'向上取整'
$("#s").text(Math.ceil((new Date - x) / 60000 + "Minutes Wasted"));
或Math.round(),它向上或向下舍入,更靠近:
$("#s").text(Math.round((new Date - x) / 60000 + "Minutes Wasted"));
  Math.round ? 
见http://www.w3schools.com/jsref/jsref_obj_math.asp
setInterval(function() {
    $("#s").text(parseInt((new Date - x) / 60000) + "Minutes Wasted");
}, 30000);
使用parseInt() 。 
