Javascript function to round number to 2 decimal places


function roundNumber(num, dec) {
	  var result = String(Math.round(num*Math.pow(10,dec))/Math.pow(10,dec));
	  if(result.indexOf('.')<0) {result+= '.';}
	  while(result.length- result.indexOf('.')<=dec) {result+= '0';}
	  return result;
	}