Skip to content

Instantly share code, notes, and snippets.

@gnrlbzik
Last active December 14, 2015 14:49
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 gnrlbzik/5103046 to your computer and use it in GitHub Desktop.
Save gnrlbzik/5103046 to your computer and use it in GitHub Desktop.
Round up number for range in JS
var max = 128,
maxLength = max.toString().length > 1 ? max.toString().length : 2,
maxRoundedUp = Math.ceil(max/Math.pow(10,maxLength) * 10) * Math.pow(10,maxLength-1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment