Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language unsigned to signed?
C language unsigned to signed?

If a is unsigned short

b is int

When converting unsigned to signed, care must be taken to ensure that "overflow" does not occur

You can use:

b=(int)a;

Such a forced conversion.

If it is unsigned short x=40000;

short y;

y=(short)x;

it will happen "overflow" (the value of y is negative).