function my_round(num, how){ if (isNaN(num)) { return 'N/A'; } if (isNaN(how)) return num; if (how < 1) return Math.round(num); var splits = num.toString(10).split("."); if ( (splits.length != 2) || (splits[1].length < (how + 1))) { return num; } else { how = Math.pow(10,how); return Math.round(num * how )/how ; }}