JavaScriptEnjoy*Study - 小数点以下第x位を四捨五入(2007/05/20修正)Enjoy*Study - Number#toFixedがブラウザによって結果が異なる場合があるRound floats - JavaScript - Snipplr端数処理 - Wikipedia function digitRound(n, x){ return !(n%1)? n : Math.round((n + new Array(x+1).join('0') + '1') * Math.pow(10,x)) / Math.pow(10,x); } is(''+digitRound( 1, 5), '1'); is(''+digitRound( 1.1, 5), '1.1'); is(''+digitRound( 1.255, 2), '1.26'); is(''+digitR