Float (C++)

C++ float is the smallest possible floating point data type available. Unlike many other languages C++ doesn't use float as the default floating point, see double for that.

It is not possible to enumerate float values, and thus it cannot be used in constructs like.

Literals
Literals that need to be differentiated from double must be followed by f or F.

float a = 1.5; // This is a double that gets converted into a float float b = 1.5f; // This is a float that gets stored in a float

Besides that float can store positive infinity, negative infinity, and NaN (not a number). NaN is generated when the result is mathematically ambiguous or impossible to determine, for example 0÷0.

Characteristics
The library consists of the following constants describing the behaviour of float
 * FLT_RADIX &mdash; base of the floating point numbers.
 * FLT_MANT_DIG &mdash; number of mantissa digits.
 * FLT_DIG &mdash; number of significant digits that can be stored.
 * FLT_MIN_EXP &mdash; minimum negative exponent.
 * FLT_MAX_EXP &mdash; maximum positive exponent.
 * FLT_MIN_10_EXP &mdash; minimum base-10 negative exponent that can be transformed into a valid float
 * FLT_MAX_10_EXP &mdash; maximum base-10 positive exponent that can be transformed into a valid float
 * FLT_EPSILON &mdash; the difference from 1.0f to the smallest possible value that is greater than 1.0f
 * FLT_MIN &mdash; the smallest possible value that is greater than 0.0f

Other C++ data types storing floating point numbers

 * double not less precise than float
 * long double not less precise than double