Revision [21376]

This is an old revision of ProPgDataConversion made by fxm on 2016-04-15 16:01:23.


Coercion and Conversion

Coercion of Numeric Data Types in Expressions

When two different data types are used in a binary operation, like + (Addition) or = (Assignment), the smaller data type is automatically promoted to the larger data type regardless of the order in which the arguments are given.

Promotions are as follows:
All unsigned integer types are handling like signed integer types for the purpose of promotion, and the most significant bit is extended (sign extension).

Conversion of Numeric Data Types

A type conversion will occur implicitly when an expression or variable is assigned, passed as a parameter to a procedure, or returned as a result from a procedure. Conversions may also be explicit when using CAST or one of the built-in conversion functions.

Integer To Integer, any combination of Signed and Unsigned
Integer to Single or Double
Double to Single
Double or Single to Integer
Implicit conversions using User Data Type operators

In the world of UDTs, implicit conversions can be controlled by means of three member procedures:
For implicit copy-construction, the compiler searches:
For implicit assignment, the compiler searches:
(a matched constructor is not searched by compiler on an implicit assignment)

See also:
Back to Programmer's Guide
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode