Actually, to be a bit more precise about my last answer, what you get from the calculations for Color is a number with 4 Billion possibilities (0-4B).
But this translates to a signed Integer of -2B to +2B (B = Billion).
And to be even more precise, the different color values (Alpha, Red, Green, Blue) are weighted in this calculation. Like this :
Alpha = a (the value you use for alpha) * 256^3
Red = r * 256^2
Green = g * 256
Blue = b
So basically only Blue increases the int of color by a 1:1 ratio.
And to be more precise again… the -2B to +2B is not reflected in the logical order.
The calculation for Color is :
color c = a * 256^3 + r * 256^2 + g * 256 + b; //this is not gonna work in code because this gives an unsigned int, not a signed one.
Now this brings a problem, because we need a signed int. To get back to your question, the weird way that the number gets to +2B and then one more and we have -2B we have to look at how it is calculated in binary.
So, to make it Short, if the result of our calculation is 0, it translates to 0 as binary (000…0) (it got 32 bits, so i‘ll abbreviate the binary parts).
If it‘s more like 64, we get 000…100…0.
If it‘s that 2B number, we get 0111…111.
Now, if it‘s that 2B number plus one, the way it‘s calculated in binary is, you add 1 to the rightmost bit, and if it‘s more than 1, you set it to 0 and change the bit to it‘s left to 1 more.
Going all the way to the leftmost bit now, we have to set it to 1 and all others end up as 0 (1000…000).
With this we have a 1 as the first Bit, which we already said, means a negative number.
And the others all being 0, means we got the -2B number. Now we can go back all the way to -1 or (111…111) in binary.
Well, i hope that last part wasn‘t too confusing… that‘s just the simplest way i could think of desrcibing it practicly.