How not of 5 is generated as -3 (~5=-3)?

i need to know in Bitwise javascript that

How not of 5 is generated as -3 (~5=-3) ?

Hi.
~5 generates -6, not -3.
Bitwise inverts the bit.
Let’s say ~5
So binary of 5 in 32-bit is 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0101
(for readability I have separated with bar)
Now ~5 inverts all digits (0 to 1 and 1 to 0 - 2’s complement)
~5 = 1111 | 1111 | 1111 | 1111 | 1111 | 1111 | 1111 | 1010 ( it is binary of -6)

Let me explain the binary of -6
Binary of 6 = 0000 | 0110
step 1: invert the digits = 1111 | 1001 (2’s complement)
step 2: add 1 = 1111 | 1010 (Note: 1 + 1 makes 10 in binary and so 0 will be down and 1 will be carry over.)
I hope it is clear now.
Thanks.