Search Results for

    Show / Hide Table of Contents

    Converter.ZigZagEncode Method

    Namespace: Riptide.Utils
    Assembly: RiptideNetworking.dll

    Overloads

    ZigZagEncode(int)

    Zig zag encodes value.

    ZigZagEncode(long)

    Zig zag encodes value.

    ZigZagEncode(int)

    Zig zag encodes value.

    public static int ZigZagEncode(int value)

    Parameters

    int value

    The value to encode.

    Returns

    int

    The zig zag-encoded 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.

    ZigZagEncode(long)

    Zig zag encodes value.

    public static long ZigZagEncode(long value)

    Parameters

    long value

    The value to encode.

    Returns

    long

    The zig zag-encoded 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.

    • Improve this Doc
    • View Source
    • Support Riptide
    In This Article
    Back to top Copyright © Tom Weiland 2022
    Made with DocFX