Question on overloading variables like short


I may be getting a little ahead of myself here, but how can you protect against trying to assign a value to variable that is larger than it can hold? I took a brute force approach to the second challenge question and just kept incrementing the value assigned to a variable of type short. I assumed (incorrectly) that when I finally assigned a value too large to fit in the short variable that it would give me error. I finally realized that wasn’t going to happen and started exploring some of the more elegant answers here in the forum. I understand the math now, but I am curious if there is an easy way to warn you if you are overloading a variable with a value larger than it’s type.

Any thoughts? Or am I not making sense at all??? Thanks.