Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the difference between signed integer variables and unsigned integer variables in C program?
What is the difference between signed integer variables and unsigned integer variables in C program?
That's because of the way computers are stored.

In a computer, the storage form of numbers is binary.

An integer is an eight-bit binary number.

For example:

xxxxxxxx

The maximum value is:111111.

Eight ones

If it is an unsigned number, then the first bit should not be a signed bit, so the value of 8 1 is:

255

If there is a sign, the first bit will be the sign bit. 0 means positive, 1 means negative,

For example, 01111means that only 7 digits are the number size, that is, 127.

111111has only seven digits, that is-127.

To put it bluntly, it means whether positive and negative numbers are unsigned or not, and can't represent positive and negative numbers.