Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language, what is a signed integer and what is an unsigned integer? Please give me another example. thank you
C language, what is a signed integer and what is an unsigned integer? Please give me another example. thank you
It is also a binary integer of 16 bits.

short int x;

Unsigned short integer y;

Signed integers consume 1 bit for symbols, and the remaining 15 bits are used to store values.

However, unsigned integers do not need sign bits, and use 16 bits to store values.

So they represent different numerical ranges.

A signed integer, where the positive number is represented by the original code, the negative number is represented by the complement, and the minimum negative number (the maximum absolute value) is10000000000000 (16 hexadecimal 0x8000). The maximum positive number is 011111111.

The unsigned number is represented by the original code, and the minimum value is 0/111111165438.

Print out these values in C language:

printf("I: %d %d\n ",(short) 0x8000,(short)0x 7 fff);

Printf("U: %u ",(unsigned short integer) 0xffff);

I: -32768 32767

U: 65535