The C++ Standard makes the following statements:
[basic.fundamental]: There are three floating-point types:
float
,double
, andlong double
. The type double provides at least as much precision as float, and the type long double provides at least as much precision as double. The set of values of the type float is a subset of the set of values of the type double; the set of values of the type double is a subset of the set of values of the type long double. The value representation of floating-point types is implementation-defined. [Note: This document imposes no requirements on the accuracy of floating-point operations; see also [support.limits]. — end note] Integral and floating-point types are collectively called arithmetic types. Specialisations of the standard library templatestd::numeric_limits
shall specify the maximum and minimum values of each arithmetic type for an implementation.[support.limits]: The headers
<limits>
([limits.syn]),<climits>;
([climits.syn], and<cfloat>
([cfloat.syn]) supply characteristics of implementation-dependent arithmetic types ([basic.fundamental]).[cfloat.syn]: The header
<cfloat>
defines all macros the same as the C standard library header<float.h>
See also: ISO C 5.2.4.2.2
This all seem to point towards the fact that the C++ standard does not want to make any statement what a float
, double
or long double
should minimally be. However, the last quoted point references <float.h>
of the C standard. This however defines a minimal requirement on the precision and range floating-point numbers.
Question: Does the statement in [cfloat.syn] imply that the same macros are defined and have an identical meaning. Or does it go one step further and also implies that the minimal requirements defined in the C-standard are followed?
5.2.4.2.2 Characteristics of floating types:
365 The values given in the following list shall be replaced by constant expressions with implementation-defined values that are greater or equal in magnitude (absolute value) to those shown, with the same sign:
...
FLT_DIG 6 DBL_DIG 10 LDBL_DIG 10 ...
Related questions: