# Bit flip only function?

Viktor Kletzhändler vkletzhaendler at swissonline.ch
Mon Jul 21 06:54:24 UTC 2014

```Thanks for the feedback.

The situation is more complicated than expected.

> 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).
>>

>> You're all trying too hard to map bit strings to integers.  Sometimes a bit string is just a bit string.  For bitwise negation, obviously, 1111 1111 should negate to 0000 0000, and 10 1010 should negate to 01 0101.  There is no consideration of repetition to infinity, or sign, or any other arithmetic numerical properties.  The bit string is simply a bit string.
>>
> But you are NOT using a tool designed for "bit strings" but for unlimited precision arithmetic. "Unlimited precision numbers", like the package uses DO have sign (represented as an infinitely repeated sign bit).
>

That would mean, mpz_com assumes that all numbers are signed two's complement representations. Therefore it silently adds a sign bit to any positive argument, and calculates the two's complement for any negative argument.

This is ok. However, that would also mean that mpz_com can't take unsigned arguments, i.e. a bit string without embedded sign, for example (unsigned int) 175. Or am I missing something again?

Thanks again
--vk

```