Skip to content

Instantly share code, notes, and snippets.

@mortenjust
Created March 17, 2012 23:53
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 mortenjust/2066741 to your computer and use it in GitHub Desktop.
Save mortenjust/2066741 to your computer and use it in GitHub Desktop.
javascript: round to nearest x
function round5(x) { return (x % 5) >= 2.5 ? parseInt(x / 5) * 5 + 5 : parseInt(x / 5) * 5; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment