Skip to content

Instantly share code, notes, and snippets.

@benadamstyles
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benadamstyles/27c1ced414aa6bb5779f to your computer and use it in GitHub Desktop.
Save benadamstyles/27c1ced414aa6bb5779f to your computer and use it in GitHub Desktop.
Return a number rounded to given decimal places
window.namespace.round=function(v,decimalPlaces) {
var d=decimalPlaces||2;
return Number(Math.round(v+'e'+d)+'e-'+d);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment