public class FloatSerializer extends Serializer
Constructor and Description |
---|
FloatSerializer()
Creates a FloatSerializer that allows uses 4 bytes to represent a float, with no loss of precision.
|
FloatSerializer(float precision,
boolean optimizePositive)
Creates a FloatSerializer that allows uses 1-5 bytes to represent a float, with a loss of precision.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Float |
readObjectData(java.nio.ByteBuffer buffer,
java.lang.Class type)
Reads an object from the buffer.
|
void |
writeObjectData(java.nio.ByteBuffer buffer,
java.lang.Object object)
Writes the object to the buffer.
|
isFinal, newInstance, readObject, setCanBeNull, writeObject
public FloatSerializer()
public FloatSerializer(float precision, boolean optimizePositive)
IntSerializer
. IntSerializer uses 1-4 bytes from
0 to 268,435,455 with "optimize positive" and -134,217,728 to 134,217,727 without. If a float multiplied by the precision
would fall outside these values, it will take 5 bytes to serialize and it may be better to use the other FloatSerializer
constructor.public java.lang.Float readObjectData(java.nio.ByteBuffer buffer, java.lang.Class type)
Serializer
readObjectData
in class Serializer
public void writeObjectData(java.nio.ByteBuffer buffer, java.lang.Object object)
Serializer
writeObjectData
in class Serializer
object
- Cannot be null.