Created
September 21, 2015 15:03
-
-
Save messenger63/10d8021af3a2208bb90e to your computer and use it in GitHub Desktop.
Show decimal only for appropriate numbers (1.23 or 2)
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
double d1 = 1.234567; | |
double d2 = 2; | |
NumberFormat nf = new DecimalFormat("##.###"); | |
System.out.println(nf.format(d1)); | |
System.out.println(nf.format(d2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment