var retain=function (num,decimal){ num = num.toString(); let index = num.indexOf('.'); if(index !== -1){ num = num.substring(0,decimal + index + 1) }else{ num = num.substring(0) } return parseFloat(num).toFixed(decimal) }
Number.prototype.toFloor = function (decimal) { let num = this.toString(); let index = num.indexOf('.'); if(index !== -1){ num = num.substring(0, decimal + index + 1) } else { num = num.substring(0) } return parseFloat(num).toFixed(decimal)}