Last active
October 9, 2017 13:15
-
-
Save rafaelmaeuer/a8480b60be900f58a765cc47286d420e to your computer and use it in GitHub Desktop.
Round to at most 2 decimal places (only if necessary) - From https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function roundToTwo(num) { | |
return +(Math.round(num + "e+2") + "e-2"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment