In C, double is a real floating-point base type. Floating-point types differ by precision, which determines the valid range of values; decimal floating-point literals such as 0.2 have type double by default. section 5.2 section 5.3
The value of 0.2
A declaration such as `double x = 0.2;` uses a double floating-point literal. The stored value may differ from the written decimal because binary fractional digits can be rounded or truncated; on one machine, 0.2 becomes approximately 0.2000000000000000111. section 5.3
Use these rules when reading or writing double values:
- Treat a decimal floating-point literal's effective value as potentially different from its decimal spelling. section 5.3
- Use hexadecimal floating-point notation when a literal should correspond more closely to a binary floating-point representation; such literals are less readable. section 5.3
float |
double |
long double |
|
| Literal | 0.2F |
0.2 |
0.2L |
| Value | 0x1.9999’9AP-3F |
0x1.9999’9999’9999AP-3 |
0xC.CCCC’ CCCC’ CCCC’ CCDP-6L |
Compare the 0.2, 0.2F, and 0.2L spellings with their corresponding floating-point types and hexadecimal forms. section 5.3






