Skip to content

Instantly share code, notes, and snippets.

@tk120404
Created March 2, 2017 12:32
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 tk120404/550fcb971ae11b8b4b2835829eab4878 to your computer and use it in GitHub Desktop.
Save tk120404/550fcb971ae11b8b4b2835829eab4878 to your computer and use it in GitHub Desktop.
decimal Adjustment in javascript
function decimalAdjust(value)
{
value = value.toString().split('e');
value = Math.round(+(value[0] + 'e' + (value[1] ? (+value[1] + 2) : 2)));
value = value.toString().split('e');
return +(value[0] + 'e' + (value[1] ? (+value[1] - 2) : -2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment