Java Reference
In-Depth Information
q = -1.0/0.0;
// Negative infinity
System.out.printf (" -1.0/0.0 = %7.2e %n " , q);
q = 0.0/0.0;
// NaN
System.out.printf ("0.0/0.0 = %5.2e %n", q);
// Multiple arguments
System.out.printf ("pi = %5.3f, e = %5.4f %n",
Math.PI, Math.E);
double r = 1.1;
// User the argument index to put the argument values
// into different locations within the string.
System.out.printf ("C = 2*%1$5.5f * %2$4.1f, "+
"A = %2$4.1f * %2$4.1f * %1$5.5f %n",
Math.PI, r);
....
The output is as follows:
1.0/3.0 = 0.333
1.0/3.0 = 0.33333
1.0/2.0 = 00000.500
1000/3.0 = 3.33e+02
3.0/4567.0 = 6.57e 04
-1.0/0.0 = -Infinity
0.0/0.0 = NaN
pi = 3.142, e = 2.7183
C = 2*3.14159 * 1.1, A = 1.1 * 1.1 * 3.14159
5.12 Web Course materials
The Web Course Chapter 5: Supplements section features a range of topics includ-
ing basic debugging techniques, setting up the Java Runtime Environment for
program users, the class file structure in the JVM, accessing the class definition
via the Class class, and more discussion of the JVM instruction set.
The Chapter 5: Te ch section provides more discussion and demonstration
programs dealing with the formatting of numerical output. The Chapter 5: Physics
section continues with numerical computing techniques, this time dealing with
integration.
Search WWH ::




Custom Search