A technique that enforces type conversions by enabling the compiler to treat one type of variable as a different type.
because Pascal has the ability to define new types, the compiler checks for parameters and argument types that are very strict when invoking a function. Therefore, in order to be able to check through the compiler, it is often necessary to convert the type of one variable to the type of another variable. For example, suppose you want to assign a value of a character type to a variable of type byte:
var c:char; B:byte;begin c:= ' a '; b:= C; The compiler will prompt for error end.
In the following code, forcing a type conversion to convert C to a byte type, actually forcing the type conversion is to tell the compiler that you know what you are doing and that you want to convert one type to another type :
var c:char; B:byte;begin c:= ' s '; b:= byte (c); The compiler does not error the end.
Note: You can force type conversions on variables only if the data lengths of the two types are the same. For example, you cannot cast a double to an integer.
In order to convert a floating-point type to an integer, use the trunc () or round () function.
To convert an integral type to a value of a floating-point number type, use the following assignment statement:
floatvar:= intvar;//directly assigns an integer variable to the double type variable
Delphi forced type conversions and type conventions