java.lang.Object
at.syntaxerror.ieee754.FloatingCodec<T>
- Direct Known Subclasses:
BinaryCodec,DecimalCodec
This class represents the base codec for encoding and decoding IEEE 754 floating point numbers.
See
BinaryCodec and DecimalCodec
for implementations.- Author:
- Thomas Kasper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Tdecode(BigInteger value) Decodes the floating point's binary representationabstract BigIntegerEncodes the floating point into its binary representationabstract BigDecimalReturns the difference between 1 and the smallest number greater than 1Returns the smallest and largest possible exponentabstract TReturns the largest possible valueabstract TReturns the smallest postive (> 0) subnormal valueabstract TReturns the smallest postive (> 0) normalized value.abstract BigIntegergetNaN(int signum) ReturnsNaN(qNaNon most processors)abstract BigIntegerReturns-Infinity's (likeDouble.NEGATIVE_INFINITY) binary representationabstract BigIntegerReturns+Infinity's (likeDouble.POSITIVE_INFINITY) binary representationabstract BigIntegergetQuietNaN(int signum) ReturnsqNaNbinary representation (on most processors)abstract BigIntegergetSignalingNaN(int signum) ReturnssNaN's binary representation (on most processors)abstract BigIntegergetZero(int signum) Returns (possibly negative) zero's binary representationprotected final voidInitializes the codec, so that the max, min and subnormal min value are guaranteed to be accessible.abstract booleanisInfinity(BigInteger value) Checks if the value isInfinity's binary representationabstract booleanisNaN(BigInteger value) Checks if the value isNaN's binary representationabstract booleanisNegative(BigInteger value) Checks if the value is negativeabstract booleanisNegativeInfinity(BigInteger value) Checks if the value is-Infinity's binary representationabstract booleanisPositive(BigInteger value) Checks if the value is positiveabstract booleanisPositiveInfinity(BigInteger value) Checks if the value is+Infinity's binary representationabstract booleanisQuietNaN(BigInteger value) Checks if the value isqNaN's binary representationabstract booleanisSignalingNaN(BigInteger value) Checks if the value issNaN's binary representation
-
Constructor Details
-
FloatingCodec
public FloatingCodec()
-
-
Method Details
-
initialize
protected final void initialize()Initializes the codec, so that the max, min and subnormal min value are guaranteed to be accessible.Without this method, codecs which memoize those values might get stuck in an endless loop, since these methods are also called from within the
Floating(int, java.math.BigDecimal)constructor -
decode
Decodes the floating point's binary representation- Parameters:
value- the binary representation- Returns:
- the decoded floating point number
-
encode
Encodes the floating point into its binary representation- Parameters:
value- the floating point number- Returns:
- the encoded binary representation
-
isPositive
Checks if the value is positive- Parameters:
value- the value- Returns:
- whether the value is positive
-
isNegative
Checks if the value is negative- Parameters:
value- the value- Returns:
- whether the value is negative
-
isInfinity
Checks if the value isInfinity's binary representation- Parameters:
value- the value- Returns:
- whether the value is
Infinity
-
isPositiveInfinity
Checks if the value is+Infinity's binary representation- Parameters:
value- the value- Returns:
- whether the value is
+Infinity
-
isNegativeInfinity
Checks if the value is-Infinity's binary representation- Parameters:
value- the value- Returns:
- whether the value is
-Infinity
-
getPositiveInfinity
Returns+Infinity's (likeDouble.POSITIVE_INFINITY) binary representation- Returns:
+Infinity
-
getNegativeInfinity
Returns-Infinity's (likeDouble.NEGATIVE_INFINITY) binary representation- Returns:
-Infinity
-
isNaN
Checks if the value isNaN's binary representation- Parameters:
value- the value- Returns:
- whether the value is
NaN
-
isQuietNaN
Checks if the value isqNaN's binary representation- Parameters:
value- the value- Returns:
- whether the value is
qNaN
-
isSignalingNaN
Checks if the value issNaN's binary representation- Parameters:
value- the value- Returns:
- whether the value is
sNaN
-
getQuietNaN
ReturnsqNaNbinary representation (on most processors)- Parameters:
signum- the signum- Returns:
qNaN
-
getSignalingNaN
ReturnssNaN's binary representation (on most processors)- Parameters:
signum- the signum- Returns:
sNaN
-
getNaN
ReturnsNaN(qNaNon most processors)- Returns:
NaN
-
getZero
Returns (possibly negative) zero's binary representation- Returns:
- zero
-
getMinSubnormalValue
Returns the smallest postive (> 0) subnormal value- Returns:
- the smallest postive value
-
getMinValue
Returns the smallest postive (> 0) normalized value.- Returns:
- the smallest postive value
-
getMaxValue
Returns the largest possible value- Returns:
- the largest value
-
getEpsilon
Returns the difference between 1 and the smallest number greater than 1- Returns:
- the difference
-
getExponentRange
Returns the smallest and largest possible exponent- Returns:
- the smallest and largest exponent
-