Unsigned Integer
Posted
by viswanathan
on Stack Overflow
See other posts from Stack Overflow
or by viswanathan
Published on 2010-04-26T06:42:56Z
Indexed on
2010/04/26
6:53 UTC
Read the original article
Hit count: 252
I was curious to know what would happen if i assign a negative value to an unsigned variable.
The code will look somewhat like this.
unsigned int nVal = 0;
nVal = -5;
It didnt give me any compiler error. When i ran the nVal was having strange value. Could it be that some 2's complement value gets assigned to nVal.
© Stack Overflow or respective owner