Skip to content

Instantly share code, notes, and snippets.

@bcalmac
Created February 20, 2016 16:10
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 bcalmac/54ab18a3f238077b4ae0 to your computer and use it in GitHub Desktop.
Save bcalmac/54ab18a3f238077b4ae0 to your computer and use it in GitHub Desktop.
Round a double
/** Rounds a double value to a specified number of decimal places. */
public static double round(double value, int scale) {
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment