Method WriteValueBitPacked
WriteValueBitPacked(FastBufferWriter, short)
Writes a 16-bit signed short to the buffer in a bit-encoded packed format. Zig-zag encoding is used to move the sign bit to the least significant bit, so that negative values are still able to be compressed. The first two bits indicate whether the value is 1, 2, or 3 bytes. If the value uses 14 bits or less, the remaining 14 bits contain the value. For performance, reasons, if the value is 15 bits or more, there will be six 0 bits, followed by the original unmodified 16-bit value in the next 2 bytes.
Declaration
public static void WriteValueBitPacked(FastBufferWriter writer, short value)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The writer to write to |
short | value | The value to pack |
WriteValueBitPacked(FastBufferWriter, ushort)
Writes a 16-bit unsigned short to the buffer in a bit-encoded packed format. The first two bits indicate whether the value is 1, 2, or 3 bytes. If the value uses 14 bits or less, the remaining 14 bits contain the value. For performance, reasons, if the value is 15 bits or more, there will be six 0 bits, followed by the original unmodified 16-bit value in the next 2 bytes.
Declaration
public static void WriteValueBitPacked(FastBufferWriter writer, ushort value)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The writer to write to |
ushort | value | The value to pack |
WriteValueBitPacked(FastBufferWriter, int)
Writes a 32-bit signed int to the buffer in a bit-encoded packed format. Zig-zag encoding is used to move the sign bit to the least significant bit, so that negative values are still able to be compressed. The first three bits indicate whether the value is 1, 2, 3, 4, or 5 bytes. If the value uses 29 bits or less, the remaining 29 bits contain the value. For performance, reasons, if the value is 30 bits or more, there will be five 0 bits, followed by the original unmodified 32-bit value in the next 4 bytes.
Declaration
public static void WriteValueBitPacked(FastBufferWriter writer, int value)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The writer to write to |
int | value | The value to pack |
WriteValueBitPacked(FastBufferWriter, uint)
Writes a 32-bit unsigned int to the buffer in a bit-encoded packed format. The first three bits indicate whether the value is 1, 2, 3, 4, or 5 bytes. If the value uses 29 bits or less, the remaining 29 bits contain the value. For performance, reasons, if the value is 30 bits or more, there will be five 0 bits, followed by the original unmodified 32-bit value in the next 4 bytes.
Declaration
public static void WriteValueBitPacked(FastBufferWriter writer, uint value)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The writer to write to |
uint | value | The value to pack |
WriteValueBitPacked(FastBufferWriter, long)
Writes a 64-bit signed long to the buffer in a bit-encoded packed format. Zig-zag encoding is used to move the sign bit to the least significant bit, so that negative values are still able to be compressed. The first four bits indicate whether the value is 1, 2, 3, 4, 5, 6, 7, 8, or 9 bytes. If the value uses 60 bits or less, the remaining 60 bits contain the value. For performance, reasons, if the value is 61 bits or more, there will be four 0 bits, followed by the original unmodified 64-bit value in the next 8 bytes.
Declaration
public static void WriteValueBitPacked(FastBufferWriter writer, long value)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The writer to write to |
long | value | The value to pack |
WriteValueBitPacked(FastBufferWriter, ulong)
Writes a 64-bit unsigned long to the buffer in a bit-encoded packed format. The first four bits indicate whether the value is 1, 2, 3, 4, 5, 6, 7, 8, or 9 bytes. If the value uses 60 bits or less, the remaining 60 bits contain the value. For performance, reasons, if the value is 61 bits or more, there will be four 0 bits, followed by the original unmodified 64-bit value in the next 8 bytes.
Declaration
public static void WriteValueBitPacked(FastBufferWriter writer, ulong value)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The writer to write to |
ulong | value | The value to pack |