Java Reference
In-Depth Information
class StrictM
{
public static void main(String[] args)
{
// CalculateE*E
double e2 = StrictMath.E * StrictMath.E;
System.out.println(e2);
}
}
Alternatively,the strictfp operator can be used at the class or the
method level. The program StrictPI.java,in the topic's CD ROM,contains
a class that is declared with the strictfp operator,as follows:
strictfp class StrictPI
On the Web
The programs StrictE.java and StrictPI.java are located in the Chapter
23folderat www.crcpress.com .
Java Basic Arithmetic
The java.lang package contains several classes that provide basic arithmetic.
The most important ones are the classes named Math and StrictMath. Both
classes expose the same fields and methods,therefore the following descrip-
tions apply to both Math,and StrictMath. As mentioned previously,strict
mathematics can be enabled at the class or method level by means of the
strictfp operator. In that case the methods and fields in java.lang.StrictMath
are always used.
Programmers note:
The so-called operator functions (+,-,*,/,and %) are Java language
primitives and,therefore,not part of java.lang or any other Java pack -
age.
Numeric constants
Two fields defined in Math and StrictMath allow declaring the common con-
stants e and Pi. They are defined as follows:
public static final double E
The value that is closer than any other to the base of the natural loga-
rithms. The actual value is:
Search WWH ::




Custom Search