public class RoundingErrors {
	public static void main(String [] args) {
		System.out.printf("1/10.0: %40.36f" , (1/10.0));
		System.out.println();
		System.out.printf("10 * 0.1: %40.36f" , (10 * 0.1));
		System.out.printf("0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1: %40.36f" , (0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1));
		double d1 = 10 * 0.1;
		double d2 = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1;
		if (d1 == d2)
			System.out.printf("equal\n");
		else
			System.out.printf("not equal\n");

		System.out.println();

		System.out.print("Added: ");
		double total = 0;
		System.out.printf("%40.36f ", total);
		for (int i = 1; i <= 15; i = i + 1) {
			total = total + 0.1;
			System.out.printf("%40.36f ", total);
		}
		System.out.println();

		System.out.print("Multiplied: ");
		total = 0;
		System.out.printf("%40.36f ", total);
		for (int i = 1; i <= 15; i = i + 1) {
			System.out.printf("%40.36f ", i * 0.1);
		}
		System.out.println();
		System.out.println();

		System.out.printf("12 * 0.1: %40.36f\n" , (12 * 0.1));
		System.out.printf("0.1 + ... + 0.1 (12): %40.36f\n" , (0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1));
		d1 = 12 * 0.1;
		d2 = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1;
		if (d1 == d2)
			System.out.printf("equal\n");
		else
			System.out.printf("not equal\n");
		System.out.println();

		System.out.printf("4 * 0.1: %40.36f\n" , (4 * 0.1));
		System.out.printf("0.1 + 0.1 + 0.1 + 0.1: %40.36f\n" , (0.1 + 0.1 + 0.1 + 0.1));
		d1 = 4 * 0.1;
		d2 = 0.1 + 0.1 + 0.1 + 0.1;
		if (d1 == d2)
			System.out.printf("equal\n");
		else
			System.out.printf("not equal\n");

		System.out.println();

		System.out.printf("17 * 0.1: %40.36f\n" , (17 * 0.1));
		System.out.printf("0.1 + ... + 0.1 (17): %40.36f\n" , (0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1));
		d1 = 17 * 0.1;
		d2 = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1;
		if (d1 == d2)
			System.out.printf("equal\n");
		else
			System.out.printf("not equal\n");


	}
}
