Converter.ZigZagDecode Method
Namespace: Riptide.Utils
Assembly: RiptideNetworking.dll
Overloads
| ZigZagDecode(int) | Zig zag decodes |
| ZigZagDecode(long) | Zig zag decodes |
ZigZagDecode(int)
Zig zag decodes value.
public static int ZigZagDecode(int value)
Parameters
| int | value |
The value to decode. |
Returns
| int | The zig zag-decoded value. |
Remarks
Zig zag encoding allows small negative numbers to be represented as small positive numbers. All positive numbers are doubled and become even numbers, while all negative numbers become positive odd numbers. In contrast, simply casting a negative value to its unsigned counterpart would result in a large positive number which uses the high bit, rendering compression via AddVarULong(ulong) and GetVarULong() ineffective.
ZigZagDecode(long)
Zig zag decodes value.
public static long ZigZagDecode(long value)
Parameters
| long | value |
The value to decode. |
Returns
| long | The zig zag-decoded value. |
Remarks
Zig zag encoding allows small negative numbers to be represented as small positive numbers. All positive numbers are doubled and become even numbers, while all negative numbers become positive odd numbers. In contrast, simply casting a negative value to its unsigned counterpart would result in a large positive number which uses the high bit, rendering compression via AddVarULong(ulong) and GetVarULong() ineffective.