The term type casting is mostly used in computer programming languages. Type casting generally refers to the conversion of values from one data type to another in a programming code. The type casting can be done in two common ways, implicitly and explicitly. Thus, there are two types of type casting as:
1. implicit/automatic type casting
2. explicit type casting
Implicit type casting as its name shows it is done automatically by the compiler. Programming languages provide a facility to convert the data types of values to another data type. When a program code is compiled, the compiler make these allowed type conversions automatically when these are needed for correct computation. As we know that in any mathematical expression, the data types of all the operands must be same but sometimes violations occur due to the programmer's mistake.
Normally in implicit type casting the lower data type can be converted to some higher data type in an expression. But if the programmer wants to convert a value from a lower data type to a higher data type, he must do it explicitly by explicit type casting. The value that we want to convert to a higher data type must be specified explicitly in the program code. Because the compiler can not do that.
1. implicit/automatic type casting
2. explicit type casting
Implicit type casting as its name shows it is done automatically by the compiler. Programming languages provide a facility to convert the data types of values to another data type. When a program code is compiled, the compiler make these allowed type conversions automatically when these are needed for correct computation. As we know that in any mathematical expression, the data types of all the operands must be same but sometimes violations occur due to the programmer's mistake.
Normally in implicit type casting the lower data type can be converted to some higher data type in an expression. But if the programmer wants to convert a value from a lower data type to a higher data type, he must do it explicitly by explicit type casting. The value that we want to convert to a higher data type must be specified explicitly in the program code. Because the compiler can not do that.