Simply as title says.
I had a line like this foo | (~(-1 >> 1));
which intension it was to keep foo as it is if it is negative and setting the first bit in case it isn't set.
(by to keep it as it is, I mean the bits)
But it just didn't change anything for foo.
after dbeugging I figgured out that -1 >> 1
evaluates to -1. I'm pretty sure right shifting does fill up from the left with 0
's But this seems to filled a 1
while that would explain why FF >> 1
would evaluate to FF
but this seems unreasonable to me aswell.
So what am I doing wrong / where is my error in my thinking about this?