Hi,
What's the difference between unsigned and signed numbers...?
thnx
Printable View
Hi,
What's the difference between unsigned and signed numbers...?
thnx
unsigned numbers: for positive numbers
signed numbers: for positive and negative numbers
whats the limit of an unsigned integer and signed integer?
Look in your limits.h file
can you tell me how to view .h files?
thnx
#include <stdio.h>
#include <limits.h>
int main(void)
{
printf("max int = %d\n", INT_MAX);
printf("max unsigned int = %u\n", UINT_MAX);
return 0;
}
signed and unsigned represent data type ranges for integers or characters. The limits .h can be found in your compilers help files. It will tell you if the integer is 16 or 32 bit. If it is 16 bit than unsigned int's range is 2^n where n = 16, whereas signed would be approximately half that number because approximately half of the range would be negative.
signed bytes: the 7th bit (bytes: 0,1,2,3,4,5,6,7) is 1
unsigned byte: 7th bit is 0
This is how (I think) techically (sp?) you sign, unsign bytes. I'm right, right?
Garfield
At the bit level, it's a little more sophisticated, but what they basically do is define a signed number so that...
0x8000 == 0
0x0000 == INT_MIN
0xFFFF == INT_MAX
There are bit-tricks they use to make this work fast, but that's pretty much the idea.