I've been trying to learn more about PHP's bitwise operators today, and I'm having a little trouble with the ~ operator. Following online tutorials, I've seen that it reverses set bits in a number. For instance, if you had a byte equal to 7:
|------------------------------------|
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|------------------------------------|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
|------------------------------------|
And reversed it using ~7:
|------------------------------------|
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|------------------------------------|
| 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
|------------------------------------|
Wouldn't that be equal to 248 and not -8?