Typecast
Enum Typecast
If a typecast function is used to convert a number related, for example, to the button pressed (in an array of buttons) to an enum type then a problem observed in that the type cast doesn't seem to work. The button press is changing the number on the input, but the enum output does not change. The answer is that most likely the two inputs to the typecast function have different representations, probably I32 and U16. The type cast is reading the high order bits of the I32 (which aren't changing) and casting them into the U16 enum output. The solution is to convert both to representations having the same length (signed and unsigned mix fine), either by changing the representation of the controls themselves or by using a convert function at the input to the type cast.