- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Type casting and Type Conversion
In this post, we will understand the difference between type casting and type conversion.
Type casting
A data type is converted to another data type using the casting operator by the developer.
It can be applied to any compatible data types and incompatible data types.
The casting operator is required to cast a data type to another type.
The destination data type could be smaller than the source data type.
It happens during the program design.
It is also known as narrowing conversion since the destination data type may be smaller than the source data type.
It is generally used in coding and competitive programming.
It is efficient.
It is reliable.
Type conversion
A data type is converted into another data type by the compiler.
It can be applied to compatible data types only.
There is no need to use a casting operator.
The destination data type can’t be smaller than source data type.
It is done at compile time.
It is also known as widening conversion since the destination data type can’t be smaller than the source data type.
It is not used frequently in coding and competitive programming since it may result in a wrong answer.
It is less efficient.
It is less reliable.