Bitwise NOT operator

I was reading this: http://www.macromedia.com/devnet/flash/articles/bitwise_operators_03.html

and it says:

With a bitwise NOT operator, I would get 6 back. This is because the bitwise NOT flips each bit in the binary representation of 9 separately, so 1001 (9 in binary) becomes 0110, which is 6 in decimal.

However:


trace (~9);

traces: -10

Am I misunderstanding something here? How does this bitwise operator operate exactly??