# C++ Floating-Point Constants

**Visual Studio .NET 2003**

Floating-point constants specify values that must have a fractional part. These values contain decimal points (**.**) and can contain exponents.

**Grammar**

*floating-constant*:*fractional-constant**exponent-part*_{opt }*floating-suffix*_{opt}

*digit-sequence**exponent-part**floating-suffix*_{opt}*fractional-constant*:*digit-sequence*_{opt}*.**digit-sequence*

*digit-sequence**.**exponent-part*:**e***sign*_{opt}*digit-sequence*

**E***sign*_{opt}*digit-sequence**sign*: one of*+**–**digit-sequence*:*digit*

*digit-sequence**digit**floating-suffix*:one of**f****l****F****L**

Floating-point constants have a "mantissa," which specifies the value of the number, an "exponent," which specifies the magnitude of the number, and an optional suffix that specifies the constant's type. The mantissa is specified as a sequence of digits followed by a period, followed by an optional sequence of digits representing the fractional part of the number. For example:

18.46 38.

The exponent, if present, specifies the magnitude of the number as a power of 10, as shown in the following example:

18.46e0 // 18.46 18.46e1 // 184.6

If an exponent is present, the trailing decimal point is unnecessary in whole numbers such as `18E0`

.

Floating-point constants default to type **double**. By using the suffixes **f** or **l** (or **F** or **L** — the suffix is not case sensitive), the constant can be specified as **float** or **long double**, respectively.

Although **long double** and **double** have the same representation, they are not the same type. For example, you can have overloaded functions like

void func( double );

and

void func( long double );