Skip to content

Instantly share code, notes, and snippets.

@sfengyuan
Created October 11, 2017 06:10
Show Gist options
  • Save sfengyuan/dbd177c47478dabb8eef90187efecf67 to your computer and use it in GitHub Desktop.
Save sfengyuan/dbd177c47478dabb8eef90187efecf67 to your computer and use it in GitHub Desktop.
Javascript
function round(value, decimals) {
return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
}
//round(1.005, 2);
// 1.01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment