Java Reference
In-Depth Information
The Class Float also contains the following methods to test for these
special encodings.
public static boolean isInfinite(float v)
Argument v is the value to be tested. Returns true if the value is positive in-
finity or negative infinity; false otherwise.
public boolean isInfinite()
Returns true if the value represented by this object is positive infinity or
negative infinity; false otherwise.
public static boolean isNaN(float v)
Argument v is the value to be tested. Returns true if the value of the argu-
ment is NaN; false otherwise.
public boolean isNaN()
ReturnstrueifthevaluerepresentedbythisobjectisNaN;falseotherwise.
Java Numeric Truncation
The class Math in the java.lang library contains several methods that allow
control over truncation of floating-point values into integers. Although
these methods are sometimes described as rounding methods, and two of
them are named round(), they in fact perform IEEE 754 truncation opera-
tions.Thetruncationmethodsarenamedceil(),floor(),rint(),andround().
Their operation is as follows:
public static double ceil(double a)
Returnsthesmallestintegervaluethatisclosesttonegativeinfinityandnot
less than the argument. The following are special cases:
1. If the argument is an integer, then the result is the same as the argument.
2. If the argument is a NaN, an infinity, positive zero, or negative zero, then the
result is the same as the argument.
3. Iftheargumentislessthanzerobutgreaterthan-1.0,thentheresultisnega-
tive zero.
The methods only parameter is a value of type double. The method's
name relates to the notion of a numeric ceiling.
public static double floor(double a)
Returns the largest integer value that is closest to positive infinity and not
greater than the argument. The following are special cases:
Search WWH ::




Custom Search