Skip to content

Instantly share code, notes, and snippets.

@jonkemp
Created December 12, 2013 15:33
Show Gist options
  • Select an option

  • Save jonkemp/7929835 to your computer and use it in GitHub Desktop.

Select an option

Save jonkemp/7929835 to your computer and use it in GitHub Desktop.
Format decimal numbers to prevent rounding errors. The first function limits decimal numbers to 2 places. The function always returns the number in number format even if you input the number as a string.
function getDecimalLimit2(mnt) {
return (Math.round(mnt * 100)) / 100;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment