SlideShare a Scribd company logo
1 of 9
Shroff S.R. Rotary Institute of Chemical Technology
Principle Supporter & Sponsor-United Phosphorous Ltd(UPL)/Shroff family
Managed By Ankleshwar Rotary Education Society
Approved by AICTE, New Delhi, Govt. of Gujarat & GTU Affiliated
 TYPE CASTING forcefully converts the
value of one type into another type.
 There are two types of the casting :-
1) IMPLICIT TYPE
2) EXPLICIT TYPE
 When compiler automatically convert data
type of the data then it is called as a implicit
type conversion.
 When Type casting forcefully converts the
value of one type into another type then it is
called as a explicit type conversion.
(type) expression;
x = (int)10.456; //10.456 converts to 10.
int a = 34; z = (float) a; //34 converts to 34.000.
y = (int) a + b; //Result of a+b is converts to integer
AUTOMATIC TYPE CONVERSION :
IT IS ALSO POSSIBLE TO STORE VALUE OF ONE
TYPE INTO A VARIABLE OF ANOTHER TYPE
WITHOUT A CAST i.e. AUTOMATIC
CONVERSION.
IT IS POSSIBLE ONLY IF THE DESTINATION
TYPE HAS ENOUGH MEMORY SPACE TO
STORE THE SOURCE VALUE.
WHEN THE OPERAND IN AN EXPRESSION
ARE OF DIFFERENT DATA TYPE, THE
LOWER TYPE IS CONVERTED INTO HIGHER
TYPE BEFORE THE OPERAND PROCEEDS.
IF ONE OPERAND IS FLOATING POINT
AND OTHER IS INTEGER , THE INTEGER
IS CONVERTED IN TO FLOATING POINT
AND THE RESULT IS FLOATING POINT.
IF ONE OF THE OPERAND IS LONG
DOUBLE, CONVERT THE LONG DOUBLE
AND RESULT IS LONG DOUBLE.
EXAMPLES :
int j ;
float k;
j=4.6; //when 4.6 is assigned to j it gets converted in
to 4
k=12; //when12 is assigned to k it converts in to
12.000000
IN THE FINAL, THE RESULT OF EXPRESSION IS CONVERTED
IN TO THE TYPE OF THE VARIABLES ON THE LEFT OF THE '='
SIGN AND IN THIS PROCESS THE FOLLOWING CHANGES
MAY OCCUR :
FLOAT TO INT CAUSES TRUNCATION OF THE FRACTIONAL
PART OF ZERO.
DOUBLE TO FLOAT CAUSES ROUNDING OF DIGITS.

More Related Content

More from Digvijaysinh Gohil

More from Digvijaysinh Gohil (20)

Hydraulic braking systems
Hydraulic braking systemsHydraulic braking systems
Hydraulic braking systems
 
Human resources management
Human resources managementHuman resources management
Human resources management
 
Traits of a good listner (Communication Skills)
Traits of a good listner (Communication Skills)Traits of a good listner (Communication Skills)
Traits of a good listner (Communication Skills)
 
Techniques of reading (Communication Skills)
Techniques of reading (Communication Skills)Techniques of reading (Communication Skills)
Techniques of reading (Communication Skills)
 
Proxemics (Communication Skills)
Proxemics (Communication Skills)Proxemics (Communication Skills)
Proxemics (Communication Skills)
 
Proxemics (2) (Communication Skills)
Proxemics (2) (Communication Skills)Proxemics (2) (Communication Skills)
Proxemics (2) (Communication Skills)
 
Paralinguistic (Communication Skills)
Paralinguistic (Communication Skills)Paralinguistic (Communication Skills)
Paralinguistic (Communication Skills)
 
Paralinguistic (2) (Communication Skills)
Paralinguistic (2) (Communication Skills)Paralinguistic (2) (Communication Skills)
Paralinguistic (2) (Communication Skills)
 
Paralinguistic (1) (Communication Skills)
Paralinguistic (1) (Communication Skills)Paralinguistic (1) (Communication Skills)
Paralinguistic (1) (Communication Skills)
 
Organizing a contents & preparing an outline
Organizing a contents & preparing an outlineOrganizing a contents & preparing an outline
Organizing a contents & preparing an outline
 
Organizing a contents & preparing an outline (2)
Organizing a contents & preparing an outline (2)Organizing a contents & preparing an outline (2)
Organizing a contents & preparing an outline (2)
 
Kinesics (Communication Skills)
Kinesics (Communication Skills)Kinesics (Communication Skills)
Kinesics (Communication Skills)
 
Kinesics (3) (Communication Skills)
Kinesics (3) (Communication Skills)Kinesics (3) (Communication Skills)
Kinesics (3) (Communication Skills)
 
Kinesics (2) (Communication Skills)
Kinesics (2) (Communication Skills)Kinesics (2) (Communication Skills)
Kinesics (2) (Communication Skills)
 
Introduction to communication (Communication Skills)
Introduction to communication (Communication Skills)Introduction to communication (Communication Skills)
Introduction to communication (Communication Skills)
 
Email etiquette (Communication Skills)
Email etiquette (Communication Skills)Email etiquette (Communication Skills)
Email etiquette (Communication Skills)
 
Welded joints (machine design & industrial drafting )
Welded joints (machine design & industrial drafting )Welded joints (machine design & industrial drafting )
Welded joints (machine design & industrial drafting )
 
Types of stresses and theories of failure (machine design & industrial drafti...
Types of stresses and theories of failure (machine design & industrial drafti...Types of stresses and theories of failure (machine design & industrial drafti...
Types of stresses and theories of failure (machine design & industrial drafti...
 
Treaded joint (machine design & industrial drafting )
Treaded joint (machine design & industrial drafting )Treaded joint (machine design & industrial drafting )
Treaded joint (machine design & industrial drafting )
 
Tolerance (machine design & industrial drafting )
Tolerance (machine design & industrial drafting )Tolerance (machine design & industrial drafting )
Tolerance (machine design & industrial drafting )
 

Recently uploaded

Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating System
Sampad Kar
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
IJECEIAES
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
BalamuruganV28
 
Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...
IJECEIAES
 
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
Madan Karki
 

Recently uploaded (20)

"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating System
 
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesLinux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptx
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdf
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
 
Introduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AIIntroduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AI
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
 

Type casting & type conversion

  • 1. Shroff S.R. Rotary Institute of Chemical Technology Principle Supporter & Sponsor-United Phosphorous Ltd(UPL)/Shroff family Managed By Ankleshwar Rotary Education Society Approved by AICTE, New Delhi, Govt. of Gujarat & GTU Affiliated
  • 2.  TYPE CASTING forcefully converts the value of one type into another type.  There are two types of the casting :- 1) IMPLICIT TYPE 2) EXPLICIT TYPE
  • 3.  When compiler automatically convert data type of the data then it is called as a implicit type conversion.  When Type casting forcefully converts the value of one type into another type then it is called as a explicit type conversion.
  • 4. (type) expression; x = (int)10.456; //10.456 converts to 10. int a = 34; z = (float) a; //34 converts to 34.000. y = (int) a + b; //Result of a+b is converts to integer
  • 5. AUTOMATIC TYPE CONVERSION : IT IS ALSO POSSIBLE TO STORE VALUE OF ONE TYPE INTO A VARIABLE OF ANOTHER TYPE WITHOUT A CAST i.e. AUTOMATIC CONVERSION.
  • 6. IT IS POSSIBLE ONLY IF THE DESTINATION TYPE HAS ENOUGH MEMORY SPACE TO STORE THE SOURCE VALUE. WHEN THE OPERAND IN AN EXPRESSION ARE OF DIFFERENT DATA TYPE, THE LOWER TYPE IS CONVERTED INTO HIGHER TYPE BEFORE THE OPERAND PROCEEDS.
  • 7. IF ONE OPERAND IS FLOATING POINT AND OTHER IS INTEGER , THE INTEGER IS CONVERTED IN TO FLOATING POINT AND THE RESULT IS FLOATING POINT. IF ONE OF THE OPERAND IS LONG DOUBLE, CONVERT THE LONG DOUBLE AND RESULT IS LONG DOUBLE.
  • 8. EXAMPLES : int j ; float k; j=4.6; //when 4.6 is assigned to j it gets converted in to 4 k=12; //when12 is assigned to k it converts in to 12.000000
  • 9. IN THE FINAL, THE RESULT OF EXPRESSION IS CONVERTED IN TO THE TYPE OF THE VARIABLES ON THE LEFT OF THE '=' SIGN AND IN THIS PROCESS THE FOLLOWING CHANGES MAY OCCUR : FLOAT TO INT CAUSES TRUNCATION OF THE FRACTIONAL PART OF ZERO. DOUBLE TO FLOAT CAUSES ROUNDING OF DIGITS.