C language compilers

Conversions and expressions

Implicit conversions

Characters and integers

Any of the following may be used in an expression where an int or unsigned int may be used.

If an int can represent all values of the original type, the value is converted to an int; otherwise it is converted to an unsigned int. This process is called ``integral promotion''.

NOTE: The promotion rules for ANSI C are different from previous releases. Use the -Xt mode to get the older behavior.

Compilation mode dependencies that affect unsigned types

Signed and unsigned integers

Integral and floating

When a floating type is converted to any integral type, any fractional part is discarded.

Float and double

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.

Usual arithmetic conversions

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'':

Next topic: Expressions
Previous topic: Function definitions

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005