Signed and unsigned integers

Hello! i'm new in this and now i'm learning the C language. I don't understand what does signed and unsigned integers. i was reading about int8_t bit signed integer or INTN_MAX Maximum positive number of the signed integer of bits N. If someone can explain me or if you have tutorial. Thx.

Post a Reply

Replies

I'm not very good with C, so I might be wrong (sorry if I am), but the difference is as follows. I am using a 1 byte int as an example. ints are usually 4 bytes.

unsigned int: all 8 bits are used to store the numeric value of the digit. so the maximum value of a single 1byte int is: 128+64+32 +16 +8+ 4+ 2+1=255, and the minimum is 0. In the even of an integer overflow error, an unsigned ints value will go from 255 to 0, and then proceed to count upwards again.

Singed Int: the last (left most) digit is used to specify whether a digit is positive or negative. the rest are used for numeric value. This means an unsigned singly byte int has a maximum value of 64+32+16+8+4+2+1=127, and a minimum value of -127. In the event of a integer overflow error, the value will go from 127 to 0, and then count downwards to -127. once -127 has been passed, it will again reset to 0 and count upwards.