FileDocCategorySizeDatePackage
FloatDoubleTime.javaAPI DocExample521Sat Apr 28 10:22:44 BST 2001None

FloatDoubleTime.java

public class FloatDoubleTime {
	/** How many times to do the loop */
	protected static final int HOW_MANY = 10000000;

	public static void main(String[] args) {
		long t0 = System.currentTimeMillis();
		float f = 0;
		for (int i=0; i<HOW_MANY; i++)
			f *= i;
		long t1 = System.currentTimeMillis();

		double d = 0;
		for (int i=0; i<HOW_MANY; i++)
			d *= i;
		long t2 = System.currentTimeMillis();

		System.out.println("Float:  " + (t1 - t0) + " " + f);

		System.out.println("Double: " + (t2 - t1) + " " + d);
	}
}