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:
Var
C : Char; B : Byte; begin B:=Byte(C); Char(B):=C; end; |
pointer variables can be typecasted to procedural types.
A typecast is an expression of the given type, which means the typecast can be followed by a qualifier:
Type
TWordRec = Packed Record L,H : Byte; end; Var P : Pointer; W : Word; S : String; begin TWordRec(W).L:=$FF; TWordRec(W).H:=0; S:=TObject(P).ClassName; |