There is no need even for any explicit conversion:
short s = 23;
int k = s;
In addition, any numeric literals (without any suffixes) are int32 anyway.
- Change
The reason for the explicit cast is not required, since a is shortalways smaller than int, therefore shortit will always fit completely into the size int, therefore potential data loss.
source
share