How to identify integer data type?

If I’m given a binary digit say 1101, how will i identify whether it is of the unsigned or signed format?

If it is unsigned, means positive, so 8+4+0+1=13

If it is signed, then by using 2’s complement notation, 1101
should be = -3.

So how do i resolve this discrepancy?

just by looking at binary representtation we cannot .thats why we need to define datatype of variable before storing any data.
so if i right
int x;
x=20;

then the last (most significant bit will be reseverd for sign)

So by defining data type as int x;
Are we defining it to be signed or unsigned?

if we have written int x; then it will be treated as signed int.

but if we explicity mention unsigned int x; then it will treated as unsigned int

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.