Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-57726

ZigZag encoder/decoder for signed 32bit and 64bit integer

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 5.1.0-rc0
    • None
    • None
    • Fully Compatible
    • Execution Team 2021-06-28, Execution Team 2021-07-12
    • 0

    Description

      Add a "ZigZag" encoder for signed integers that stores the sign bit as the least significant bit. Two's complement is using the most significant bit resulting in a large bit difference for -1 vs 0.

      With ZigZag, Simple-8b encoder does then not have to know about signed integers and can treat everything as unsigned.

      For 32bit integers ZigZag encoding would look like this:
      zigzag = (n << 1) ^ (n >> 31)

      Attachments

        Issue Links

          Activity

            People

              luke.bhan@mongodb.com Luke Bhan (Inactive)
              jackson.xie@mongodb.com Jackson Xie (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: