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 CBORObjectcreateExtendedFloat(double value) Creates an "extended" CBORfloatobject.intlength()Get length of the serializedIEEE754object.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 CBORfloatobject.This constructor only implements support for finite ("regular") floating point numbers. That is, a
Double.NaNargument causes aCBORExceptionto be thrown.CBORObject.getFloat64()is the decoder counterpart.For
NaNandInfinitysupport seecreateExtendedFloat(double).- Parameters:
value- Floating-point value
-
-
Method Details
-
createExtendedFloat
Creates an "extended" CBORfloatobject.Unlike
CBORFloat(double), this method also supports theDouble.NaN,Double.POSITIVE_INFINITY, andDouble.NEGATIVE_INFINITYnon-finite variants.CBORObject.getExtendedFloat64()is the decoder counterpart.Note that return type is either
CBORFloatorCBORNonFinite, 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 serializedIEEE754object.Note that you must cast a
CBORObjecttoCBORFloatin order to accesslength().- Returns:
- Length in bytes: 2, 4, or 8.
-