Interface FloatingPointType<T extends java.lang.Number & java.lang.Comparable<T>>
-
- Type Parameters:
T
- kind of elements
- All Known Implementing Classes:
IEEEDoubleType
,IEEEFloatType
public interface FloatingPointType<T extends java.lang.Number & java.lang.Comparable<T>>
Title: Floating Point Type
Description: Interface to provide a common set of methods for Float and Double types
Copyright: Copyright (c) 2009
Company: Clark & Parsia, LLC.
- Author:
- Mike Smith
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
cast(java.lang.Object o)
Casts an object to the class described by thisFloatingPointType
object.T
decrement(T n)
T
getNaN()
Gets the Not-a-Number constant for the type.T
getNegativeInfinity()
Gets the negative infinity constant for the type.T
getPositiveInfinity()
Gets the positive infinity constant for the type.T
increment(T n)
java.lang.Number
intervalSize(T lower, T upper)
Count the number of floating point values in an inclusive intervalboolean
isInstance(java.lang.Object o)
Determine if the specifiedObject
is assignment compatible with the object represented by thisFloatingPointType
.boolean
isNaN(T f)
Returnstrue
if this floating point value is a Not-a-Number (NaN) value,false
otherwise.
-
-
-
Method Detail
-
cast
T cast(java.lang.Object o)
Casts an object to the class described by thisFloatingPointType
object.- Parameters:
o
- the object to cast- Returns:
o
in the appropriate type- Throws:
java.lang.ClassCastException
- if the object is not null and is no assignable to the typeT
.
-
decrement
T decrement(T n)
- Parameters:
n
- The value to decrement Return the next floating point value in the direction of-Inf
.
- Returns:
- If
n > -Inf
, the next floating point value in the direction of-Inf
. If
n == -Inf
,-Inf
. - Throws:
java.lang.IllegalArgumentException
- ifn.isNaN()
-
getNaN
T getNaN()
Gets the Not-a-Number constant for the type.- Returns:
T.NaN
-
getNegativeInfinity
T getNegativeInfinity()
Gets the negative infinity constant for the type.- Returns:
T.NEGATIVE_INFINITY
-
getPositiveInfinity
T getPositiveInfinity()
Gets the positive infinity constant for the type.- Returns:
T.POSITIVE_INFINITY
-
increment
T increment(T n)
- Parameters:
n
- The value to increment Return the next floating point value in the direction of+Inf
.
- Returns:
- If
n < +Inf
, the next floating point value in the direction of+Inf
. If
n == +Inf
,+Inf
. - Throws:
java.lang.IllegalArgumentException
- ifn.isNaN()
-
intervalSize
java.lang.Number intervalSize(T lower, T upper)
Count the number of floating point values in an inclusive interval- Parameters:
lower
- The lower bound of the intervalupper
- The upper bound of the interval- Returns:
- If
lower.equals(upper)
,1
. Else, the number of floating point values betweenlower
andupper
plus2
-
isInstance
boolean isInstance(java.lang.Object o)
Determine if the specifiedObject
is assignment compatible with the object represented by thisFloatingPointType
. Typically implemented as a wrapper forT.class.isInstance(Object)
.- Parameters:
o
- the object to check- Returns:
true
ifo
is an instance ofT
,false
else.
-
isNaN
boolean isNaN(T f)
Returnstrue
if this floating point value is a Not-a-Number (NaN) value,false
otherwise.- Parameters:
f
- the value to be tested- Returns:
true
if the argument is NaN, elsefalse
-
-