The way you did this simply reinterprets fewer bits in one memory location. He does not change them.
You probably want to use the max and min functions to detect when the value is outside of short , and assign the maximum or minimum value to the short when it happens.
int n = 1000000; short value = n > Short.MAX_VALUE ? Short.MAX_VALUE : n < Short.MIN_VALUE ? Short.MIN_VALUE : (short)n;
Update: more compact:
import static java.lang.Math.max; import static java.lang.Math.min;
source share