|
|
Any of the following may be used in an expression where an int or unsigned int may be used.
When a floating type is converted to any integral type, any fractional part is discarded.
A float is promoted to double or long double, or a double is promoted to long double without a change in value.
The actual rounding behavior that is used when a floating point value is converted to a smaller floating point value depends on the rounding mode in effect at the time of execution. The default rounding mode is ``round to nearest.'' See ``Floating point operations'' and the IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Std 754-1985) for a more complete discussion of rounding modes.
Some binary operators convert the types of their operands in order to yield a common type, which is also the type of the result. These are called the ``usual arithmetic conversions'':
long double > double > float > unsigned long long > long long> unsigned long > long > unsigned int > intHowever, if one operand is an unsigned type and the other is a potentially larger signed type, and they are the same size, they are converted to the unsigned version of the signed type. For example, in the case of long + unsigned int, both operands are converted to unsigned long. In the case of unsigned long + long long, the unsigned long is converted to long long.