Javascript Number decorateFloat(decimals, decSeparator)
Number.prototype.decorateFloat = function (decimals, decSeparator) { if(decSeparator == undefined) decSeparator = '.'; var price = this; var decPattern = ''; for(var i = 0; i < decimals; i++) decPattern += '0'; price = price.roundFloat(decimals);/* w w w . j a va2 s. c om*/ var split = price.toString().split('.'); if(split[1] == undefined) split[1] = ''; var decor = decPattern.substring(split[1].length, decimals); split[1] = split[1]+decor; return split.join(decSeparator); };