Created
February 20, 2016 16:10
-
-
Save bcalmac/54ab18a3f238077b4ae0 to your computer and use it in GitHub Desktop.
Round a double
This file contains hidden or 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
/** 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