Class CBORNonFinite
- All Implemented Interfaces:
Cloneable,Comparable<CBORObject>
Due to the fact that platform support for non-finite floating-point objects
beyond the three simple forms, "quiet" NaN, Infinity,
and -Infinity is limited, this implementation separates
non-finite floating-point objects from "regular" floating-point numbers.
The latter are dealt with by the CBORFloat class.
Since non-finite data can be "anything" that makes sence for consuming
applications, long is used as value container.
For a detailed description and user guide, turn to: Non-Finite Numbers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CBORNonFinitecreatePayload(long payload) Creates a payload object.longGet actual non-finite object (value).longGet expanded non-finite object (value).longGet payload data.booleangetSign()Get sign bit of non-finite object.booleanisNaN()Check if non-finite object is aNaN.booleanisSimple()Check if non-finite object is simple.intlength()Get length of non-finite object.setSign(boolean sign) Set sign bit of non-finite object.Methods inherited from class org.webpki.cbor.CBORObject
checkForUnread, clone, compareTo, encode, equals, getArray, getBigInteger, getBoolean, getBytes, getDateTime, getEpochTime, getExtendedFloat64, getFloat16, getFloat32, getFloat64, getInt16, getInt32, getInt64, getInt8, getMap, getSimple, getString, getTag, getUint16, getUint32, getUint64, getUint8, hashCode, isNull, scan, toDiagnosticNotation, toString
-
Constructor Details
-
CBORNonFinite
public CBORNonFinite(long value) Creates a non-finite floating-point number.The constructor takes a
16,32, or64-bit non-finite number inIEEE754encoding.See also
CBORFloat(double)andCBORFloat.createExtendedFloat(double).- Parameters:
value- Non-finite number expressed as along- Throws:
CBORException- If the argument is not within the non-finite number space
-
-
Method Details
-
createPayload
Creates a payload object.For details turn to Payload Option.- Parameters:
payload- Payload data- Returns:
CBORNonFinite
-
getPayload
public long getPayload()Get payload data.This method is the "consumer" counterpart to
createPayload(long).- Returns:
- Payload
-
setSign
Set sign bit of non-finite object.- Parameters:
sign- Sign bit expressed as aboolean.true= 1,false= 0.- Returns:
CBORNonFinite- See Also:
-
getSign
public boolean getSign()Get sign bit of non-finite object.This method returns
trueif the sign bit is1, elsefalseis returned.- Returns:
boolean.- See Also:
-
length
public int length()Get length of non-finite object.Note that you must cast a
CBORObjecttoCBORNonFinitein order to accesslength().- Returns:
- Length in bytes: 2, 4, or 8.
-
isSimple
public boolean isSimple()Check if non-finite object is simple.This method returns
trueif the non-finite object is aDouble.NaN,Double.POSITIVE_INFINITY, orDouble.NEGATIVE_INFINITY, elsefalseis returned.- Returns:
boolean.
-
isNaN
public boolean isNaN()Check if non-finite object is aNaN.This method returns
truefor all conformantNaNvariants, elsefalseis returned..- Returns:
boolean.
-
getNonFinite
public long getNonFinite()Get actual non-finite object (value).This method returns the value of a non-finite object. The value is provided in the most compact form based on CBOR serialization rules.
- Returns:
IEEE754non-finite number coded as along
-
getNonFinite64
public long getNonFinite64()Get expanded non-finite object (value).This method returns the value of a non-finite object after it has been expanded to 64 bits. That is, a received
7c01will be returned as7ff0040000000000.- Returns:
IEEE754non-finite number coded as along
-