I'm working on functions for bitwise NOT, AND, OR, XOR in a big integer library.
I've implemented negative values with a boolean sign flag (not as twos-complement).
I'm thinking about how the boolean sign flag should be dealt with in these functions, and was wondering if there were any maths experts who had an opinion on this.
For example, is there a strict mathematical rule for calculating the value of
My intuition says to attempt the same operation on the boolean sign flags of the operands. So in the example above with the AND function, the result would be negative if both operand1 AND operand2 were both negative, otherwise the result would be positive. But that might not be correct.
Another idea is to say these functions make no sense when the signs are different, and that an overflow exception should be raised.
I tried asking Google, but it just gave me answers for the arithmetic operators plus, minus, multiply, etc.