Arithmetic Conversions

Arithmetic Conversions - 3: Arithmetic Conversions If...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
3: Arithmetic Conversions If operands of an expression are of different types, then these operands will have their types changed, using arithmetic conversions . A lower precision type is promoted to a higher precision type according to the following hierarchy: int unsigned long
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Assignment Conversions RHS of assignment of different type than LHS => implicit conversion RHS is converted Exercise care with demotions char c = 2; /* c is ^B */ int i; c++; /* ^C */ c += '0'; /* '3' */ i = c - '0'; /* 3 */ c = 'a' + i; /* 'd' */
Background image of page 2
Function Call Conversions Argument conversion If type mismatch between formal and passed parameters, implicit conversion just like actual assignment
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Arithmetic Conversions - 3: Arithmetic Conversions If...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online