P
puzzlecracker
what does it do?
#define BLACKBOX(x) ((x)&((x)-1))
#define BLACKBOX(x) ((x)&((x)-1))
puzzlecracker said:what does it do?
#define BLACKBOX(x) ((x)&((x)-1))
puzzlecracker said:what does it do?
#define BLACKBOX(x) ((x)&((x)-1))
Luke said:Clears the least significant set bit in x. This works on all unsigned
numbers and all signed numbers (except "sign-magnitude" negative even
numbers).
Michael said:For unsigned integers x and signed integers x in 2s complement
with x>(integer type's minimum value), this clears the least
significant set bit.
It also works for 1s complement signed integers and
x!=0 && x!=1 && x>(integer type's minimum value)
Clears the least significant set bit in x. This works on all unsigned
numbers and all signed numbers (except "sign-magnitude" negative even
numbers).
Inputting the integer '8' causes the "function" to return zero. Not
suprizing, since the original poster is a known troll.
Raymond said:Inputting the integer '8' causes the "function" to return zero.
Yes, exactly as Luke said. What's your point?
Not suprizing, since the original poster is a known troll.
What are you on about?
Peter said:What do you think it does?
If you want to 'test' clc, at least try to be original.
Ack.
No, consider the following (high bit is sign-bit):
1c or 2c(C99) sm
x : 10000000 10000000 10000000 01111111
x - 1: 10000000 01111111 10000000 10000000
& : 10000000 00000000 10000000 00000000
The result could be a trap representation.
Note also that C89 potentially allows negative representations
beyond 2c, 1c and sm.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.