we know if we want to store num=-1 in 32 bit signed int its bits representation will look like
1000 0000 0000 0000 0000 0000 0000 0001
but if I do like this num=-1
unsigned int num1 = num then num1 bit representation will look like 1111 1111 1111 1111 1111 1111 1111 1111.
we also know that in unsigned int msb does not represent sign ,it contributes to magnitude ,I want to know why there are all ones in num1 representation how can I predict the value for -2 in unsigned int
Note I was trying all the operation in cpp language
#include<bits/stdc++.h>
using namespace std;
int main(){
unsigned int num = -1;
///i want to know what will be the bit representation of num=-2
while(num){
cout<<(num&1);
num>>=1;
}
}