1's complement using ~ in C/C++ -
i using visual studio 2013.
tried ~
operator 1's complement:
int = 10; cout << ~a << endl;
output -11
but for
unsigned int = 10; cout << ~a << endl;
the output 4294967296
i don't why output -11
in case of signed int
. please me confusion.
when put number 10 32-bit signed or unsigned integer, get
0000 0000 0000 0000 0000 0000 0000 1010
when negate it, get
1111 1111 1111 1111 1111 1111 1111 0101
these 32 bits mean 4294967285 unsigned integer, or -11 signed integer (your computer represents negative integers two's complement). can mean 32-bit floating point number or 4 8-bit characters.
bits don't have "absolute" meaning. can represent anything, depending on how "look" @ them (which type have).
Comments
Post a Comment