Click here to Skip to main content
15,890,282 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Examples, Guidance or Condolances Pin
Nagy Vilmos26-Feb-17 22:18
professionalNagy Vilmos26-Feb-17 22:18 
GeneralRe: Examples, Guidance or Condolances Pin
Mark_Wallace26-Feb-17 22:29
Mark_Wallace26-Feb-17 22:29 
GeneralA code example in your question .. is distracting? Pin
harold aptroot26-Feb-17 1:09
harold aptroot26-Feb-17 1:09 
GeneralRe: A code example in your question .. is distracting? Pin
OriginalGriff26-Feb-17 1:20
mveOriginalGriff26-Feb-17 1:20 
GeneralRe: A code example in your question .. is distracting? Pin
Eddy Vluggen26-Feb-17 1:25
professionalEddy Vluggen26-Feb-17 1:25 
GeneralRe: A code example in your question .. is distracting? Pin
harold aptroot26-Feb-17 1:33
harold aptroot26-Feb-17 1:33 
GeneralRe: A code example in your question .. is distracting? Pin
Eddy Vluggen26-Feb-17 1:43
professionalEddy Vluggen26-Feb-17 1:43 
GeneralRe: A code example in your question .. is distracting? Pin
harold aptroot26-Feb-17 1:56
harold aptroot26-Feb-17 1:56 
Any example I give here would make people miss the point..
But whatever, let's go for it.

OP wrote:
How does x & -x isolate the rightmost set bit? For example in C:
C++
int rightMostBit(int x) {
    return x & -x;
}
Tags: [two's complement arithmetic]

Typical reply:
Oh boy, negating an int in C? Can't do that, it might be INT_MIN and then negating it will bring about the apocalypse. Actually even ignoring that for a second, what if it's not a two's complement negative but something else, with one's complement negatives you'd just get zero and with sign-magnitude representation you'd get abs(x). See, it doesn't isolate the rightmost set bit in the first place.

All of which is (as far as I know) true enough, but irrelevant to the question.
GeneralRe: A code example in your question .. is distracting? Pin
Kornfeld Eliyahu Peter26-Feb-17 1:36
professionalKornfeld Eliyahu Peter26-Feb-17 1:36 
GeneralRe: A code example in your question .. is distracting? Pin
User 5924126-Feb-17 1:51
User 5924126-Feb-17 1:51 
GeneralRe: A code example in your question .. is distracting? Pin
OriginalGriff26-Feb-17 2:34
mveOriginalGriff26-Feb-17 2:34 
GeneralRe: A code example in your question .. is distracting? Pin
Kornfeld Eliyahu Peter26-Feb-17 2:36
professionalKornfeld Eliyahu Peter26-Feb-17 2:36 
GeneralRe: A code example in your question .. is distracting? Pin
OriginalGriff26-Feb-17 2:45
mveOriginalGriff26-Feb-17 2:45 
GeneralRe: A code example in your question .. is distracting? Pin
User 5924126-Feb-17 2:45
User 5924126-Feb-17 2:45 
GeneralRe: A code example in your question .. is distracting? Pin
Sander Rossel26-Feb-17 5:33
professionalSander Rossel26-Feb-17 5:33 
GeneralRe: A code example in your question .. is distracting? Pin
OriginalGriff26-Feb-17 5:42
mveOriginalGriff26-Feb-17 5:42 
GeneralRe: A code example in your question .. is distracting? Pin
F-ES Sitecore26-Feb-17 3:00
professionalF-ES Sitecore26-Feb-17 3:00 
GeneralRe: A code example in your question .. is distracting? Pin
Richard Deeming26-Feb-17 6:00
mveRichard Deeming26-Feb-17 6:00 
GeneralRe: A code example in your question .. is distracting? Pin
PIEBALDconsult26-Feb-17 3:20
mvePIEBALDconsult26-Feb-17 3:20 
GeneralRe: A code example in your question .. is distracting? Pin
TheGreatAndPowerfulOz26-Feb-17 7:21
TheGreatAndPowerfulOz26-Feb-17 7:21 
GeneralRe: A code example in your question .. is distracting? Pin
Jon McKee26-Feb-17 8:41
professionalJon McKee26-Feb-17 8:41 
GeneralRe: A code example in your question .. is distracting? Pin
Jon McKee26-Feb-17 8:36
professionalJon McKee26-Feb-17 8:36 
GeneralRe: A code example in your question .. is distracting? Pin
Bryian Tan26-Feb-17 20:24
professionalBryian Tan26-Feb-17 20:24 
GeneralRe: A code example in your question .. is distracting? Pin
Brady Kelly27-Feb-17 15:44
Brady Kelly27-Feb-17 15:44 
GeneralThat's totally wrong... Pin
Kornfeld Eliyahu Peter26-Feb-17 0:32
professionalKornfeld Eliyahu Peter26-Feb-17 0:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.