To encode a synchsafe integer: 1. Convert the decimal value to binary. 2. Split the binary value into 7-bit chunks, starting from the rightmost bit. 3. Prepend each chunk with a zero bit. 4. Put the chunks back together to form a new binary value. 5. Convert the new binary value back to decimal.
Example: To encode the decimal value 300, we first convert it to binary: 100101100. We split this binary value into three 7-bit chunks: 0010110 0, 0110010 0, and 0000001 1. We prepend each chunk with a zero bit to get: 00010110 00, 00110010 00, and 00000001 11. We put these chunks back together to get the binary value 00010110 00001100 00000001 11, which is equal to 7700687 in decimal.
To decode a synchsafe integer: 1. Convert the decimal value to binary. 2. Split the binary value into 8-bit chunks, starting from the leftmost bit. 3. Remove the leftmost zero bit from each chunk. 4. Put the chunks back together to form a new binary value. 5. Convert the new binary value back to decimal.
Example: Given the synchsafe integer 7700687, we convert it to binary: 11101000 01100110 00000010 11. We split this binary value into four 8-bit chunks: 11101000, 01100110, 00000010, and 11. We remove the leftmost zero bit from each chunk to get: 1110100, 1100110, 0000010, and 1. We put these chunks back together to get the binary value 11101001 10011000 00001001, which is equal to 300 in decimal.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-07-22 11:00:00 +0000
Seen: 31 times
Last updated: Oct 06 '22
How can I add up the value of a different layer's field when it intersects with a polygon in QGIS?
What is the method for de-linearizing the value of the depth buffer?
What is the expected outcome of the math.floor function in terms of the return value?
What is the method to retrieve the value of a checkbox using react-hook-form?
What is the method for obtaining the value of a attribute using Xpath?