Skip to content

Instantly share code, notes, and snippets.

@gabrielstuff
Created August 24, 2013 21:08
Show Gist options
  • Select an option

  • Save gabrielstuff/6330432 to your computer and use it in GitHub Desktop.

Select an option

Save gabrielstuff/6330432 to your computer and use it in GitHub Desktop.
Round function with float approximation. Very basic but useful. Usage : betterRound(number, approximate);
function betterRound(number, roundness){
if(roundness === undefined){
roundness = 0;
}
var round = Math.pow(10, roundness);
return Math.ceil(number * round) / round;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment