what are default integer values?

后端 未结 3 830
情话喂你
情话喂你 2021-01-14 10:43

I read somewhere that default floating point values like 1.2 are double not float.
So what are default integer values like 6

3条回答
  •  离开以前
    2021-01-14 11:12

    Just if someone is interested:

    C11 §6.4.4.1/5:

    The type of an integer constant is the first of the corresponding list in which its value can be represented.

    ---------------------------------------------------------------------------
    Suffix        Decimal Constant              Octal/Hexadecimal Constant
    ---------------------------------------------------------------------------
    none          int                           int
                  long int                      unsigned int
                  long long int                 unsigned long int
                                                long long int
                                                unsigned long long int
    ---------------------------------------------------------------------------
    u or U        unsigned int                  unsigned int
                  unsigned long int             unsigned long int
                  unsigned long long int        unsigned long long int
    ---------------------------------------------------------------------------
    l or L        long int                      long int
                  long long int                 unsigned long int
                                                long long int
                                                unsigned long long int
    ---------------------------------------------------------------------------
    Both u or U   unsigned long int             unsigned long int
    and l or L    unsigned long long int        unsigned long long int
    ---------------------------------------------------------------------------
    ll or LL      long long int                 long long int
                                                unsigend long long int
    ---------------------------------------------------------------------------
    Both u or U   unsigned long long int        unsigned long long int
    and ll or LL
    ---------------------------------------------------------------------------
    

    As for the prefix §6.4.4.1/3:

    A decimal constant begins with a nonzero digit and consists of a sequence of decimal digits. An octal constant consists of the prefix 0 optionally followed by a sequence of the digits 0 through 7 only. A hexadecimal constant consists of the prefix 0x or 0X followed by a sequence of the decimal digits and the letters a (or A) through f (or F) with values 10 through 15 respectively.

提交回复
热议问题