Bit flip only function?
Richard at Damon-Family.org
Sun Jul 20 22:46:31 UTC 2014
On 7/20/14, 12:22 PM, Viktor Kletzhändler wrote:
> Thanks for the reply.
> mpz_com seems to do more than flipping.
> For example, for a base-2 number
> mpz_com ( 1111 1111 ) returns ( -1 0000 0000 )
> whereas I would like _dcom ( 1111 1111 ) returns ( 0 ).
> Am I missing something?
I suspect that what you are missing is that the binary value 1111 1111
if it really means 255 decimal is REALLY the bit pattern
+0 1111 1111 (to store the sign bit), and thus the complement would be
-1 0000 0000 (where the sign is used to indicate that the leading bit is
replicated to infinity (but can be ignored for value).
More information about the gmp-discuss