Skip to content

Commit

Permalink
correct the wrong comment for encodeZigZag
Browse files Browse the repository at this point in the history
Summary:
The comment for encodeZigZag(x) is wrong.

Should be encodeZigZag(x) == -2*x - 1, as

encodeZigZag(-1) = 1

and

encodeZigZag(-2) = 3

Closes facebook/folly#2046

X-link: facebook/folly#2072

Reviewed By: Gownta

Differential Revision: D58789263

Pulled By: yfeldblum

fbshipit-source-id: af4d16b606cdc39ec930f16218ebf53637a86815
  • Loading branch information
faithk7 authored and facebook-github-bot committed Jun 21, 2024
1 parent 6f20b1e commit b74a626
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion third-party/folly/src/folly/Varint.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Expected<uint64_t, DecodeVarintError> tryDecodeVarint(Range<T*>& data);
* encoding negative values using Varint would use up 9 or 10 bytes.
*
* if x >= 0, encodeZigZag(x) == 2*x
* if x < 0, encodeZigZag(x) == -2*x + 1
* if x < 0, encodeZigZag(x) == -2*x - 1
*/

inline uint64_t encodeZigZag(int64_t val) {
Expand Down

0 comments on commit b74a626

Please sign in to comment.