Hexadecimal floating-point literals

Real hexadecimal floating constants, which are a C99 feature, consist of the following:

The significant part represents a rational number and is composed of the following:

The optional fraction part is a period followed by a sequence of hexadecimal digits.

The exponent part indicates the power of 2 to which the significant part is raised, and is an optionally signed decimal integer. The type suffix is optional. The full syntax is as follows:

Read syntax diagramSkip visual syntax diagramHexadecimal floating-point literal syntax
 
>>-+-0x-+------------------------------------------------------->
   '-0X-'
 
     .------------------.     .------------------.
     V                  |     V                  |
>--+---+--------------+-+--.----+-digit_0_to_f-+-+--| exponent |-+-->
   |   +-digit_0_to_f-+         '-digit_0_to_F-'                 |
   |   '-digit_0_to_F-'                                          |
   | .------------------.                                        |
   | V                  |                                        |
   +---+-digit_0_to_f-+-+--.--| exponent |-----------------------+
   |   '-digit_0_to_F-'                                          |
   | .------------------.                                        |
   | V                  |                                        |
   '---+-digit_0_to_f-+-+--| exponent |--------------------------'
       '-digit_0_to_F-'
 
>--+---+-------------------------------------------------------><
   +-f-+
   +-F-+
   +-l-+
   '-L-'
 
Exponent:
 
                  .--------------.
                  V              |
|--+-p-+--+----+----digit_0_to_9-+------------------------------|
   '-P-'  +-+--+
          '- --'
 

The suffix f or F indicates a type of float, and the suffix l or L indicates a type of long double. If a suffix is not specified, the floating-point constant has a type double. You can omit either the whole-number part or the fraction part, but not both. The binary exponent part is required to avoid the ambiguity of the type suffix F being mistaken for a hexadecimal digit.



[ Top of Page | Previous Page | Next Page | Contents | Index ]