GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Bitwise NOT in C++

The bitwise not in c++ is giving weird result.

(~2)=-3.Actually I know the reason the entire bit frame is getting inverted.I need (~2) to be 1 how can this happen.?

This should satisfy for other numbers as well.

asked Jan 10 by nb
edited Jan 10 by nb