Floating constants

suggest change

A floating constant contains a decimal point, an exponent, or both:

Suffix Type Examples
none double 3.1415926, 3e6
f, F float 3.1415926f, 2.1e-6F
l, L long double 3.1415926L, 1e126L

3f is invalid because 3 is an integer constant. Write 3.0f, 3.f, or 3e0f. Prefer uppercase L for long double because lowercase l can be mistaken for the digit one.

Hexadecimal floating constants use a binary exponent introduced by p or P:

double value = 0x1.8p+1; /* Exactly 3.0. */

The sign is a separate unary operator, not part of the constant itself.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents