2 ms·
It's a little known fact that >> in C++ (and I suspect in C as well) on a signed type is not guaranteed to be an arithmetical shift. It's up to the implementati
by pandaman 14y ago
It's a little known fact that >> in C++ (and I suspect in C as well) on a signed type is not guaranteed to be an arithmetical shift. It's up to the implementation and most implementation choose arithmetical shift for signed and logical shift for unsigned but this does not mean that all the implementations do this.
So some of this tricks are contingent on the particular implementation specific behavior.