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 T
decode
(BigInteger value) Decodes the floating point's binary representationabstract BigInteger
Encodes the floating point into its binary representationabstract BigDecimal
Returns the difference between 1 and the smallest number greater than 1Returns the smallest and largest possible exponentabstract T
Returns the largest possible valueabstract T
Returns the smallest postive (> 0
) subnormal valueabstract T
Returns the smallest postive (> 0
) normalized value.abstract BigInteger
getNaN
(int signum) ReturnsNaN
(qNaN
on most processors)abstract BigInteger
Returns-Infinity
's (likeDouble.NEGATIVE_INFINITY
) binary representationabstract BigInteger
Returns+Infinity
's (likeDouble.POSITIVE_INFINITY
) binary representationabstract BigInteger
getQuietNaN
(int signum) ReturnsqNaN
binary representation (on most processors)abstract BigInteger
getSignalingNaN
(int signum) ReturnssNaN
's binary representation (on most processors)abstract BigInteger
getZero
(int signum) Returns (possibly negative) zero's binary representationprotected final void
Initializes the codec, so that the max, min and subnormal min value are guaranteed to be accessible.abstract boolean
isInfinity
(BigInteger value) Checks if the value isInfinity
's binary representationabstract boolean
isNaN
(BigInteger value) Checks if the value isNaN
's binary representationabstract boolean
isNegative
(BigInteger value) Checks if the value is negativeabstract boolean
isNegativeInfinity
(BigInteger value) Checks if the value is-Infinity
's binary representationabstract boolean
isPositive
(BigInteger value) Checks if the value is positiveabstract boolean
isPositiveInfinity
(BigInteger value) Checks if the value is+Infinity
's binary representationabstract boolean
isQuietNaN
(BigInteger value) Checks if the value isqNaN
's binary representationabstract boolean
isSignalingNaN
(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
ReturnsqNaN
binary 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
(qNaN
on 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
-