Is (FFFFFF XOR HexColor) equivalent to (FFFFFF - HexColor)?

26 Views Asked by At

I have searched Stack Overflow for color inversion algorithms. Most responses involve separating channel values and calculating the respective differences of FF and said values, e.g.

    HexColor = 3DB5B1
    InvRed = FF - 3D = C2
    InvGreen = FF - B5 = 4A
    InvBlue = FF - B1 = 4E

Or less frequently, calculating the bitwise exclusive OR of FFFFFF and HexColor, e.g.

    FFFFFF XOR 3DB5B1 = C24A4E

Isn't (FFFFFF XOR HexColor) equivalent to (FFFFFF - HexColor)? That is.

    InvHexColor = FFFFFF - HexColor

And one need not separate the channels or use a bitwise operator.

I cannot find an example that fails, but I lack a proof.

It is not clear to me how I might use the answers of Bitwise XORing two numbers results in sum or difference of the numbers. Can anyone suggest how I can apply which identity or analysis to FFFFFF and an arbitrary six digit hexadecimal color code?

0

There are 0 best solutions below