import java.text.DecimalFormat; /*-------------------------------------  実数型変数の表示 PrintDouble -------------------------------------*/ public class PrintDouble { public static void main(String[] args) { double d; float f; d=0.55555555555555555555; f=0.55555555555555555555f; DecimalFormat fm00=new DecimalFormat("0"); DecimalFormat fm01=new DecimalFormat("0.0"); DecimalFormat fm02=new DecimalFormat("0.00"); DecimalFormat fm03=new DecimalFormat("0.000"); DecimalFormat fm04=new DecimalFormat("0.0000"); DecimalFormat fm05=new DecimalFormat("0.00000"); DecimalFormat fm06=new DecimalFormat("0.000000"); DecimalFormat fm07=new DecimalFormat("0.0000000"); DecimalFormat fm08=new DecimalFormat("0.00000000"); DecimalFormat fm09=new DecimalFormat("0.000000000"); DecimalFormat fm10=new DecimalFormat("0.0000000000"); DecimalFormat fm11=new DecimalFormat("0.00000000000"); DecimalFormat fm12=new DecimalFormat("0.000000000000"); DecimalFormat fm13=new DecimalFormat("0.0000000000000"); DecimalFormat fm14=new DecimalFormat("0.00000000000000"); DecimalFormat fm15=new DecimalFormat("0.000000000000000"); DecimalFormat fm16=new DecimalFormat("0.0000000000000000"); DecimalFormat fm17=new DecimalFormat("0.00000000000000000"); DecimalFormat fm18=new DecimalFormat("0.000000000000000000"); DecimalFormat fm19=new DecimalFormat("0.0000000000000000000"); DecimalFormat fm20=new DecimalFormat("0.00000000000000000000"); System.out.print("\n倍精度型の値を表示します\n"); System.out.print("----+----1----+----2----+----3\n"); System.out.println(fm00.format(d)); System.out.println(fm01.format(d)); System.out.println(fm02.format(d)); System.out.println(fm03.format(d)); System.out.println(fm04.format(d)); System.out.println(fm05.format(d)); System.out.println(fm06.format(d)); System.out.println(fm07.format(d)); System.out.println(fm08.format(d)); System.out.println(fm09.format(d)); System.out.println(fm10.format(d)); System.out.println(fm11.format(d)); System.out.println(fm12.format(d)); System.out.println(fm13.format(d)); System.out.println(fm14.format(d)); System.out.println(fm15.format(d)); System.out.println(fm16.format(d)); System.out.println(fm17.format(d)); System.out.println(fm18.format(d)); System.out.println(fm19.format(d)); System.out.println(fm20.format(d)); System.out.print("\n\n"); System.out.print("\n単精度型の値を表示します\n"); System.out.print("----+----1----+----2----+----3\n"); System.out.println(fm00.format(f)); System.out.println(fm01.format(f)); System.out.println(fm02.format(f)); System.out.println(fm03.format(f)); System.out.println(fm04.format(f)); System.out.println(fm05.format(f)); System.out.println(fm06.format(f)); System.out.println(fm07.format(f)); System.out.println(fm08.format(f)); System.out.println(fm09.format(f)); System.out.println(fm10.format(f)); System.out.println(fm11.format(f)); System.out.println(fm12.format(f)); System.out.println(fm13.format(f)); } }