Comments (3)
@Logofile Do you have context on why this was changed?
The old version (~ 1 year ago) was correct:
(n << 1) ^ (n >> 31)
for sint32
(n << 1) ^ (n >> 63)
for sint64
This more closely matched our code as well
from protocolbuffers.github.io.
I think what we want is (n + n) ^ (n < 0)
, which is easy to prove is equivalent to the above formula (but more compact)
from protocolbuffers.github.io.
Nvm, your version is correct. Because of the right-shift behavior of signed integers we need the -
like you found: (n+n) ^ -(n < 0)
. I think it's best to just use the version we have in the code though to make it more maintainable though
from protocolbuffers.github.io.
Related Issues (20)
- Protocol Buffers HOT 2
- Fortran | Protocol buffers | Object oriented programming HOT 1
- `optional` field Has methods HOT 3
- RSS feed is empty HOT 1
- Programming Guides HOT 1
- Language Guide (proto 2)
- Protocol Buffers/medjham/medium/hulu/netfex/livestream HOT 1
- Naming convention for function names doesn't make sense HOT 4
- Java Wrapper class should be more obious HOT 1
- Protocol Buffer Basics: Python HOT 3
- Protocol Buffers HOT 1
- Dart Generated Code: Enumerations HOT 2
- Odd spacing in the sidebar around the Kotlin section HOT 4
- Protocol Buffers HOT 1
- JSON changes without transition not listed as breaking HOT 1
- C++ Generated Code Guide oneof HOT 1
- Language Guide (proto 3) has wrong date on google search results page HOT 1
- Protocol Buffers
- Protocol Buffers
- Protocol Buffers Well-Known Types HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protocolbuffers.github.io.