What is the difference between type casting and data type conversion? Please describe with example. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 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.

29th Jan 2020, 6:38 PM
Neha
2 Antworten
+ 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;
29th Jan 2020, 7:11 PM
Avinesh
Avinesh - avatar
+ 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
29th Jan 2020, 7:08 PM
Oma Falk
Oma Falk - avatar