C Numeric Constants

C numeric constants can be any of the following:

        — an optional sign             - or +

        — an integer part              a combination of digits 0 through 9

        — a period                         .

        — a fractional part            a sequence of digits 0 through 9

        — an optional exponent    e or E, followed by an optionally signed sequence of one or more digits

For example, the following floating-point constant contains both the optional and required parts: +1.15e-12.

The following floating-point constant contains only the required parts: 1.0

The following formal grammar summarizes the rules for the C numeric constants:

C-constant:

  C-integer-constant
  floating-point-constant

  character-constant

 

C-integer-constant:

  [1-9][0-9]*
  0[bB][01]*

  0[0-7]*

  0[xX][0-9a-fA-F]*

 

floating-point-constant:
  integer-part.[ fractional-part ] [ exponent-part ]

 

integer-part:
  [0-9]*

 

fractional-part:
  [0-9]*

 

exponent-part:
  [eE][+-][0-9]*

  [eE][0-9]*