Lecture overview -- Keyboard shortcut: 'u'  Previous page: Type conversion - Grand Overview -- Keyboard shortcut: 'p'  Next page: Explicit type conversion -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 23 : 42
Notes about C++
Basic facilities
Implicit type conversions

"Integral og floating-point types can be mixed freely in assignments and expressions"

  • The C++ Programming Language: Page 833
 

  • "Fundamental types can be converted to each other in a bewildering number of ways"

  • Promotions

    • A kind of normalization to certain integer types and floating point types before arithmetic operations

  • Usual Arithmetic conversions

    • Convert arguments of binary operators to a common type

  • Conversion to boolean

    • From pointers, integers, and floating point types

    • Non-zero value transformed to true and zero to false

  • Conversion between integer types

    • Unsigned: Cutting off bits

    • Signed: Implementation dependent

  • Conversion between floating point and integer types

    • May cause loss of information, or may be undefined (in case of range problems)