RBG value editing problem/question

In my C++ book, there is an example program that will invert the colors of a .bmp (24-bit Bitmap) image. I don't think I need to copypaste the whole program for my problem, but here's the part I'm concerned with:

I can't figure out why there is there a difference in those particular areas, can someone tell me what's happening? If the whole code is needed, I'll post it, though I think the problem is understanding how bitmap images are processed and not the code itself. Thanks for reading.

-1 value of signed byte is value 255 in unsigned byte.
-2 value of signed byte is value 254 in unsigned byte.
-3 value of signed byte is value 253 in unsigned byte.
...
I believe RGB value is treated as unsigned byte. Therefore:

compare the values in the 2 arrays, you can see why "Each RBG value is +1 compared to the correctly-inverted image." And there is one value that is greatly different from the correct value, which resulted in glichy areas, where the pixels has RGB values = (1,0,0) (0,1,0), (0,0,1), (1,1,0)...

For example:
- (1,1,0) ~ black after invert should be (254,254,255) ~ white. But the value 255 is 0 if you use "0 - color" method, which resulted in (255,255,0) -> yellow
- (1,0,0) ~ black after invert should be (254,255,255) ~ white. But the value 255 is 0 if you use "0 - color" method, which resulted in (255,0,0) -> red

to fix this, either +255 or -1 to the rgb values... which is the same as "255 - color" method ~.~

Thanks for the replies, Stauricus and tntxtnt.
Absolute value wouldn't work the same, I don't think so at least, which can be seen by tntxtnt's explanation.

tntxtnt, thanks for the explanation on the RBG values, it makes much more sense now.

I also realized that, for example, 300 value becomes 44 on the .bmp image, since 300 - 256 = 44.

These questions popped up when I first noticed some glitchy stuff when using rand() to slightly change the RBG values of an image. When I get the chance I'll be sure to apply what you said to prevent it from glitching like that, thanks again.