Skip to content

Instantly share code, notes, and snippets.

@benjamincharity
Created June 16, 2015 10:39
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 benjamincharity/003346bd9be2184e083a to your computer and use it in GitHub Desktop.
Save benjamincharity/003346bd9be2184e083a to your computer and use it in GitHub Desktop.
Force number to show two decimal places (with rounding). Source: http://stackoverflow.com/questions/6134039/format-number-to-always-show-2-decimal-places
var input = 4.537;
var result = parseFloat(Math.round(num3 * 100) / 100).toFixed(2); // 4.54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment