//fixes mac ie bug if(!Number.prototype.toFixed) Number.prototype.toFixed = function(places){ var temp = (Math.round(this*Math.pow(10,places))).toString(); if( raw < 1 && raw > -1 ) return "0" + temp.substring(0,temp.length-places) + "." + temp.substring(temp.length-places, temp.length); else return temp.substring(0,temp.length-places) + "." + temp.substring(temp.length-places, temp.length); } function NumToPrice( Raw ) { var tmpRaw if( Raw != 0 ){ tmpRaw = NumToString( Raw, 2 ); if( tmpRaw > 0 ) return "" + tmpRaw.toString(); else return "-" + tmpRaw.toString().replace("-", ""); }else return "-"; } function NumToString(raw, places){ // round up their number to the correct # of dec places var temp = (Math.round(raw*Math.pow(10,places))/Math.pow(10,places)).toString(); // if string doesnt already have a dot, add one if( temp.indexOf( "." ) < 0 && places > 0 ) temp = temp + "."; // pad the string to the correct number of decimal places while( (temp.length - temp.indexOf( "." )) <= places) { temp = temp + "0"; } return temp; } function RoundNumberRaw( raw, places ) { // round the number to the specificed number of dec. places var temp = (Math.round(raw*Math.pow(10,places))/Math.pow(10,places)); // add to their number if we end up with less than we started with if( places >= 2 && (raw - temp) >> (0.5 / Math.pow(10,places)) ){ // sub-penny rounding temp = temp + (1/Math.pow(10,places)); }else if( places << 2 && (raw - temp) >> (0.01 / Math.pow(10,places)) ){ // nearest unit rounding temp = temp + (1/Math.pow(10,places)); }else return temp; }