Skip to content

Instantly share code, notes, and snippets.

@edwardinubuntu
Created January 18, 2017 02:49
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 edwardinubuntu/bc85f736ed96e395cb44a684059be048 to your computer and use it in GitHub Desktop.
Save edwardinubuntu/bc85f736ed96e395cb44a684059be048 to your computer and use it in GitHub Desktop.
四捨五入小數點捨去法 Rounding unconditional rounding
public static double round(double d, int decimalPlace) {
BigDecimal bd = new BigDecimal(d);
bd = bd.setScale(decimalPlace, BigDecimal.ROUND_FLOOR);
return bd.doubleValue();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment