摘要: 1: function randomBetween(min,max) 2: { 3: return min+Math.floor(Math.random()*(max-min+1)); 4: } 可以通过math.random生成伪随机数 1: return Math.random();// a number between 0 and ... 阅读全文
posted @ 2008-05-12 17:11 looping 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 1: function roundTo(base,precision) 2: { 3: var m=Math.pow(10,precision); 4: var a=Math.round(base*m)/m; 5: return a; 6: } math.round函数 将数字转化为最接近的整数。 bt... 阅读全文
posted @ 2008-05-12 16:51 looping 阅读(173) 评论(0) 推荐(0) 编辑