Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- public class Demo {
- public static void main(String[] args) {
- DecimalFormat df = new DecimalFormat("#.###");
- double numberOne = 2.3265683;
- double numberTwo = 12.000000;
- System.out.printf("%s%n", df.format(numberOne)); // 2.327
- System.out.printf("%s", df.format(numberTwo)); // 12
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment