Conversions              Usual Arithmetic Conversions
 
    Many binary operators that expect arithmetic type operands cause
    conversions.  The purpose of conversions is to yield a common type,
    which becomes the type of the result.  This pattern is called "the
    usual arithmetic conversions."  Here are the step-by-step tests for
    conversions, according to the ANSI Draft of the C programming
    language.  To use this table, scan it from top to bottom, and use the
    first rule that applies.
 
 
  ------------------------------ Conversion --------------------------------
          If either operand                  then convert the
          has the type                       other operand to
  ---------------------------------------------------------------------------
          long double                        long double
 
          double                             double
 
          float                              float
 
          unsigned long int                  unsigned long int
 
          long int                           long int
 
          char                               int
          enum                               int
          short                              int
 
          unsigned int                       unsigned int
  ---------------------------------------------------------------------------
 
       Note:    If after performing the integral promotions shown in the
                next to last line of the table (char, enum and short
                convert to int), either operand then has type unsigned
                int, the other operand is converted to unsigned int (as
                shown in the last line of the table).
 
                For any situation not covered by the table, both operands
                are of type int.

This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster