A variable can be considered a single factor in an expression. It can therefore be typecast as well. A variable can be typecast to any type, provided the type has the same size as the original variable.
It is a bad idea to typecast integer types to real types and vice versa. It’s better to rely on type assignment compatibility and using some of the standard type changing functions.
Note that variable typecasts can occur on either side of an assignment, i. e. the following are both valid typecasts:
But not all typecasts can be assigned to. The above will work, but e.g. a typecast to single cannot be assigned to.
Pointer variables can be typecast to procedural types, but not to method pointers.
A typecast is an expression of the given type, which means the typecast can be followed by a qualifier: