Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
What is the difference between signed and unsigned integer.Can any one help me?
Posted
Comments
CPallini 6-Aug-14 3:15am    
The sign?

Simple: one can contain negative values, the other can't.

To expand a little, a signed value uses one bit (usually the top, or most significant bit) to indicate if the number is positive or negative, and an unsigned integer uses all available bits for the number - so the number of different values that can be held is the same, but the range of values is different.
Assume we used a 4 bit processor (to make the numbers easier)
Unsigned:
Bits   Value (decimal)
0000     0
0001     1
0010     2
0011     3
0100     4
0101     5
0110     6
0111     7
1000     8
1001     9
1010    10
1011    11
1100    12
1101    13
1110    14
1111    15
Signed:
Bits   Value (decimal)
0000     0
0001     1
0010     2
0011     3
0100     4
0101     5
0110     6
0111     7
1000    -8
1001    -7
1010    -6
1011    -5
1100    -4
1101    -3
1110    -2
1111    -1
-8 in this scheme is sometimes treated as "minus zero" but you can probably ignore that!
 
Share this answer
 
Comments
CPallini 6-Aug-14 3:15am    
5.
Manoj Kumar Choubey 6-Aug-14 7:57am    
5
See here[^] for a general explanation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900