Error on use of common annode on ide example

Hello, I am new to Arduino, I tested some basic examples and noticed on one of them what it looks to be an error.

the example is part of the commonication -> SerialCallResponseASCI

      // if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
      red = 255 - constrain(red, 0, 255);
      green = 255 - constrain(green, 0, 255);
      blue = 255 - constrain(blue, 0, 255);

if this is common annode it should invert the signals, substracting from 255 is not the same as inverting.
I tried on the example sending different rgb colors and they are all wrong on my rgb led when mixing different values (between 1 and 254)

I changed this code for:

      //red = 255 - constrain(red, 0, 255);
      //green = 255 - constrain(green, 0, 255);
      //blue = 255 - constrain(blue, 0, 255);
      red = constrain(red, 0, 255) ^ B11111111;
      green = constrain(green, 0, 255) ^ B11111111;
      blue = constrain(blue, 0, 255) ^ B11111111;

this fixed the colors by inverting the bist, please let me know if I am wrong

If you subtract from 0xFF where every bit is set, then any bit that is set in the number you're subtracting becomes a zero in the answer, and any bit that is 0 in the number you're subtracting becomes a 1 in the answer. How exactly is that not inverting the bits?

 11111111
-01101010
=10010101

As Delta_G says, but in decimal:-

0: 255-0=255
100: 255-100=155
200: 255-200=55
255: 255-255=0

That looks inverted to me too:- 0 to 255 gives 255 to 0.