+ 2
What is the difference between type casting and data type conversion? Please describe with example.
I want to know the difference between type casting and data type conversion.
2 Answers
+ 2
Type conversion is rather implicit and is taken care by the compiler whereas type casting has to be explicitly performed in order to change one data type to other.
Eg- Type conversion
int x = 10;
float f = x;
Eg- Type casting
float f = 10.25;
int x = (int) f;
+ 4
Casting is a term describing syntax (hence the Syntactic meaning). Conversion is a term describing what actions are actually taken behind the scenes (and thus the Semantic meaning). A cast-expression is used to convert explicitly an expression to a given type.
Quote from https://stackoverflow.com/questions/3166840/what-is-the-difference-between-casting-and-conversion