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 CBORNonFinite
createPayloadObject
(long payload) Creates a payload object.long
Get actual non-finite object (value).long
Get expanded non-finite object (value).long
Get payload data.boolean
getSign()
Get sign bit of non-finite object.boolean
isNaN()
Check if non-finite object is aNaN
.boolean
isSimple()
Check if non-finite object is simple.int
length()
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 inIEEE
754
encoding.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
-
createPayloadObject
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
createPayloadObject(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
true
if the sign bit is1
, elsefalse
is returned.- Returns:
boolean
.- See Also:
-
length
public int length()Get length of non-finite object.Note that you must cast a
CBORObject
toCBORNonFinite
in 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
true
if the non-finite object is aDouble.NaN
,Double.POSITIVE_INFINITY
, orDouble.NEGATIVE_INFINITY
, elsefalse
is returned.- Returns:
boolean
.
-
isNaN
public boolean isNaN()Check if non-finite object is aNaN
.This method returns
true
for all conformantNaN
variants, elsefalse
is 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:
IEEE
754
non-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
7c01
will be returned as7ff0040000000000
.- Returns:
IEEE
754
non-finite number coded as along
-