java.lang.Object
java.lang.Number
at.syntaxerror.ieee754.Floating<T>
- All Implemented Interfaces:
Serializable,Comparable<T>
- Author:
- Thomas Kasper
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFloating(int signum, FloatingType type) Creates a new special floating-point number.Floating(int signum, BigDecimal value) Creates a new floating-point number with the given signum and value. -
Method Summary
Modifier and TypeMethodDescriptionintdoubleencode()Encodes this number into its binary representationfloatReturns theBigDecimalstored.abstract FloatingCodec<T> getCodec()Returns thecodecused for this floating-point numberintReturns the signum, which is either-1(negative),0(zero), or1(positive)intintValue()booleanisFinite()Checks whether this number isfinitebooleanChecks whether this number isInfinitybooleanisNaN()booleanChecks whether this number is negativebooleanChecks whether this number is-InfinitybooleanChecks whether this number is-0booleanChecks whether this number is positivebooleanChecks whether this number is+InfinitybooleanChecks whether this number is+0.booleanChecks whether this number isqNaNbooleanChecks whether this number issNaNbooleanisZero()Checks whether this number is0longtoString()Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
POSITIVE
public static final int POSITIVE- See Also:
-
NEGATIVE
public static final int NEGATIVE- See Also:
-
-
Constructor Details
-
Floating
Creates a new floating-point number with the given signum and value.If the value exceeds the
maximum value, the value becomesInfinitywith the respective sign.If the value is less than the
minimum value, the values becomes0.- Parameters:
signum- the signum (either-1,0, or1; must be the same asthe value's signum)value- the value
-
Floating
Creates a new special floating-point number.- Parameters:
signum- the signum (either-1or1)type- the special type (must not beFloatingType.FINITE)
-
-
Method Details
-
getBigDecimal
Returns theBigDecimalstored. Fails if the number is notfinite.- Returns:
- the stored
BigDecimal
-
getSignum
public int getSignum()Returns the signum, which is either-1(negative),0(zero), or1(positive)- Returns:
- the signum
-
isPositive
public boolean isPositive()Checks whether this number is positive- Returns:
- whether this number is positive
-
isNegative
public boolean isNegative()Checks whether this number is negative- Returns:
- whether this number is negative
-
isFinite
public boolean isFinite()Checks whether this number isfinite- Returns:
- whether this number is finite
-
isNaN
public boolean isNaN()- Returns:
- whether this number is
NaN
-
isSignalingNaN
public boolean isSignalingNaN()Checks whether this number issNaN- Returns:
- whether this number is
sNaN
-
isQuietNaN
public boolean isQuietNaN()Checks whether this number isqNaN- Returns:
- whether this number is
qNaN
-
isInfinity
public boolean isInfinity()Checks whether this number isInfinity- Returns:
- whether this number is
Infinity
-
isPositiveInfinity
public boolean isPositiveInfinity()Checks whether this number is+Infinity- Returns:
- whether this number is
+Infinity
-
isNegativeInfinity
public boolean isNegativeInfinity()Checks whether this number is-Infinity- Returns:
- whether this number is
-Infinity
-
isZero
public boolean isZero()Checks whether this number is0- Returns:
- whether this number is
0
-
isPositiveZero
public boolean isPositiveZero()Checks whether this number is+0.Note: The
signumvalue0also classifies as positive in this case- Returns:
- whether this number is
+0
-
isNegativeZero
public boolean isNegativeZero()Checks whether this number is-0- Returns:
- whether this number is
-0
-
encode
Encodes this number into its binary representation- Returns:
- the binary representation
-
intValue
public int intValue() -
longValue
public long longValue() -
floatValue
public float floatValue()- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
compareTo
- Specified by:
compareToin interfaceComparable<T extends Floating<T>>
-
toString
-
getCodec
Returns thecodecused for this floating-point number- Returns:
- the codec
-