Class CBORFloat
- All Implemented Interfaces:
Cloneable
,Comparable<CBORObject>
float
objects.
Numbers are in the IEEE
754
format
using the length 16
, 32
, and 64
bit on the "wire". Which
length to use is governed by the size and precision
required to (minimally) correctly represent a number.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CBORObject
createExtendedFloat
(double value) Creates an "extended" CBORfloat
object.int
length()
Get length of the serializedIEEE
754
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
-
CBORFloat
public CBORFloat(double value) Creates a CBORfloat
object.This constructor only implements support for finite ("regular") floating point numbers. That is, a
Double.NaN
argument causes aCBORException
to be thrown.CBORObject.getFloat64()
is the decoder counterpart.For
NaN
andInfinity
support seecreateExtendedFloat(double)
.- Parameters:
value
- Floating-point value
-
-
Method Details
-
createExtendedFloat
Creates an "extended" CBORfloat
object.Unlike
CBORFloat(double)
, this method also supports theDouble.NaN
,Double.POSITIVE_INFINITY
, andDouble.NEGATIVE_INFINITY
non-finite variants.CBORObject.getExtendedFloat64()
is the decoder counterpart.Note that return type is either
CBORFloat
orCBORNonFinite
, depending on if the argument is a "regular" floating-point value of one of the non-finite variants.- Parameters:
value
- Floating-point value- Returns:
CBORObject
- Throws:
CBORException
- See Also:
-
length
public int length()Get length of the serializedIEEE
754
object.Note that you must cast a
CBORObject
toCBORFloat
in order to accesslength()
.- Returns:
- Length in bytes: 2, 4, or 8.
-