Created
June 28, 2011 13:19
-
-
Save itoz/1051110 to your computer and use it in GitHub Desktop.
JAVA 四捨五入
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
//四捨五入 | |
BigDecimal origin = new BigDecimal(f); | |
BigDecimal res = origin.setScale(0,BigDecimal.ROUND_HALF_UP); | |
result = res.shortValue(); | |
or | |
Math.round(f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment