SlideShare a Scribd company logo
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

Hydraulic braking systems
Hydraulic braking systemsHydraulic braking systems
Hydraulic braking systems
Digvijaysinh Gohil
 
Human resources management
Human resources managementHuman resources management
Human resources management
Digvijaysinh Gohil
 
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)
Digvijaysinh Gohil
 
Techniques of reading (Communication Skills)
Techniques of reading (Communication Skills)Techniques of reading (Communication Skills)
Techniques of reading (Communication Skills)
Digvijaysinh Gohil
 
Proxemics (Communication Skills)
Proxemics (Communication Skills)Proxemics (Communication Skills)
Proxemics (Communication Skills)
Digvijaysinh Gohil
 
Proxemics (2) (Communication Skills)
Proxemics (2) (Communication Skills)Proxemics (2) (Communication Skills)
Proxemics (2) (Communication Skills)
Digvijaysinh Gohil
 
Paralinguistic (Communication Skills)
Paralinguistic (Communication Skills)Paralinguistic (Communication Skills)
Paralinguistic (Communication Skills)
Digvijaysinh Gohil
 
Paralinguistic (2) (Communication Skills)
Paralinguistic (2) (Communication Skills)Paralinguistic (2) (Communication Skills)
Paralinguistic (2) (Communication Skills)
Digvijaysinh Gohil
 
Paralinguistic (1) (Communication Skills)
Paralinguistic (1) (Communication Skills)Paralinguistic (1) (Communication Skills)
Paralinguistic (1) (Communication Skills)
Digvijaysinh Gohil
 
Organizing a contents & preparing an outline
Organizing a contents & preparing an outlineOrganizing a contents & preparing an outline
Organizing a contents & preparing an outline
Digvijaysinh Gohil
 
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)
Digvijaysinh Gohil
 
Kinesics (Communication Skills)
Kinesics (Communication Skills)Kinesics (Communication Skills)
Kinesics (Communication Skills)
Digvijaysinh Gohil
 
Kinesics (3) (Communication Skills)
Kinesics (3) (Communication Skills)Kinesics (3) (Communication Skills)
Kinesics (3) (Communication Skills)
Digvijaysinh Gohil
 
Kinesics (2) (Communication Skills)
Kinesics (2) (Communication Skills)Kinesics (2) (Communication Skills)
Kinesics (2) (Communication Skills)
Digvijaysinh Gohil
 
Introduction to communication (Communication Skills)
Introduction to communication (Communication Skills)Introduction to communication (Communication Skills)
Introduction to communication (Communication Skills)
Digvijaysinh Gohil
 
Email etiquette (Communication Skills)
Email etiquette (Communication Skills)Email etiquette (Communication Skills)
Email etiquette (Communication Skills)
Digvijaysinh Gohil
 
Welded joints (machine design & industrial drafting )
Welded joints (machine design & industrial drafting )Welded joints (machine design & industrial drafting )
Welded joints (machine design & industrial drafting )
Digvijaysinh Gohil
 
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...
Digvijaysinh Gohil
 
Treaded joint (machine design & industrial drafting )
Treaded joint (machine design & industrial drafting )Treaded joint (machine design & industrial drafting )
Treaded joint (machine design & industrial drafting )
Digvijaysinh Gohil
 
Tolerance (machine design & industrial drafting )
Tolerance (machine design & industrial drafting )Tolerance (machine design & industrial drafting )
Tolerance (machine design & industrial drafting )
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

Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
bijceesjournal
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
PreethaV16
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
ycwu0509
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
edwin408357
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
PIMR BHOPAL
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 

Recently uploaded (20)

Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 

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.