Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- public class DecimalFormatExample {
- public static void main(String[] args) {
- double number = 123.456;
- //15 digits after decimal point
- DecimalFormat decimalFormat = new DecimalFormat(".000000000000000");
- System.out.println(decimalFormat.format(number));
- //15 digits before and after decimal point
- DecimalFormat decimalFormat2 = new DecimalFormat("000000000000000.000000000000000");
- System.out.println(decimalFormat2.format(number));
- //15 digits after decimal point
- System.out.printf("%.15f", number);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement