function numberval(valor){ if(valor.length>0){ return parseFloat(valor); }else{ return 0; } } function nformat(number, decimals){ thousandsSep='.'; decPoint =','; number = (number + '').replace(/[^0-9+\-Ee.]/g, '') var n = !isFinite(+number) ? 0 : +number var prec = !isFinite(+decimals) ? 0 : Math.abs(decimals) var sep = (typeof thousandsSep === 'undefined') ? ',' : thousandsSep var dec = (typeof decPoint === 'undefined') ? '.' : decPoint var s = '' var toFixedFix = function (n, prec) { var k = Math.pow(10, prec) return '' + (Math.round(n * k) / k).toFixed(prec) } // @todo: for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.') if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep) } if ((s[1] || '').length < prec) { s[1] = s[1] || '' s[1] += new Array(prec - s[1].length + 1).join('0') } return s.join(dec) } function snformat(num,n){ var _nnum = Math.abs(Math.floor(num)-num); if(_nnum > 0){ return nformat(num,n); }else{ return nformat(num,0); } } function des_nformat(num){ miles='.'; centimos=','; num = num.split(miles).join(''); num = parseFloat(num.replace(centimos,'.')); if(isNaN(num)) return(0); return(num); } function moneyformat(num){ return nformat(num,2); } function des_moneyformat(num){ return des_nformat(num); } function roundNumber(rnum,rlength){ return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength); } var STR_PAD_LEFT = 1; var STR_PAD_RIGHT = 2; var STR_PAD_BOTH = 3; function pad(str, len, pad, dir) { if (typeof(len) == "undefined") { var len = 0; } if (typeof(pad) == "undefined") { var pad = ' '; } if (typeof(dir) == "undefined") { var dir = STR_PAD_RIGHT; } if (len + 1 >= str.length) { switch (dir){ case STR_PAD_LEFT: str = Array(len + 1 - str.length).join(pad) + str; break; case STR_PAD_BOTH: var right = Math.ceil((padlen = len - str.length) / 2); var left = padlen - right; str = Array(left+1).join(pad) + str + Array(right+1).join(pad); break; default: str = str + Array(len + 1 - str.length).join(pad); break; } } return str; }