You bind an integer (int) to a short integer (short). Since an int is larger than a short int in terms of the number of bits supported, there is a chance that the original int has a value that is too large for the short int. To notify you of this problem, during the execution of the note that the cast - as with any act when the value is passed to something less - is not allowed.
On a 32-bit system, for example, int stores values ββin 32 bits and short storage values ββin 16 bits. What will happen to a 32-bit int with a value of 4,000,000, which will be transferred to a 16-bit short? There is not enough bits in the short variable to hold the value of 4,000,000. What would you expect to see in this case? Runtime alerts you to this overflow condition.
Jeffferguson
source share