Created
January 18, 2017 02:49
-
-
Save edwardinubuntu/bc85f736ed96e395cb44a684059be048 to your computer and use it in GitHub Desktop.
四捨五入小數點捨去法 Rounding unconditional rounding
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
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