Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to implicitly convert INT to SHORT type?
How to implicitly convert INT to SHORT type?
It seems that implicit conversion can only be converted from short type to int type, and vice versa.

The code is as follows:

int I = 5;

Short b=(short) I vote.

Short data type (C/C++):

In C language, short is one of defining a family of integer variables. For example, short I; Represents the variable I that defines a short integer.

Length:

According to different program compilers, the number of bytes defined by short is different.

The short integer variable defined by the standard cannot be less than 16 bits, that is, two bytes.

Limits.h in the compiler header folder defines the size that short can represent: short minimum ~ SHRT _ maximum.

In 32-bit platforms such as windows(32-bit), the short is generally 16 bits.

Function:

1.c++ & amp; C short is a data type ranging from -32768 to +32767.

2.*** There are two kinds:

Unsigned short I; I can represent 0~65535.

Signed (default) short i; I can refer to -32768~+32767.