如果 C 标准允许 "double == float",那么为什么它需要 DBL_DECIMAL_DIG 和 DBL_DIG >= 10(而不是 >=6)?
If C standard allows "double == float", then why it requires DBL_DECIMAL_DIG and DBL_DIG >= 10 (and not >=6)?
N2596 工作草案 — 2020 年 12 月 11 日 ISO/IEC 9899:202x (E):
The values given in the following list shall be replaced by implementation-defined constant expressions with values that are greater than or equal to those shown:
#define DBL_MAX 1E+37
#define FLT_MAX 1E+37
The values given in the following list shall be replaced by implementation-defined constant expressions with (positive) values that are less than or equal to those shown:
#define DBL_MIN 1E-37
#define FLT_MIN 1E-37
The values given in the following list shall be replaced by implementation-defined constant expressions that are greater or equal in magnitude (absolute value) to those shown, with the same
sign:
#define DBL_DECIMAL_DIG 10
#define DBL_DIG 10
#define FLT_DECIMAL_DIG 6
#define FLT_DIG 6
问题:如果标准允许 DBL_MAX == 1E+37
和 DBL_MIN == 1E-37
(即 double
的属性 == float
的属性),那么为什么它需要 DBL_DECIMAL_DIG >= 10
和 DBL_DIG >= 10
(而不是 DBL_DECIMAL_DIG >= 6
和 DBL_DIG >= 6
)?
P.S。也许我错过了什么。请指正方向
If C standard allows "double == float", then why it requires DBL_DECIMAL_DIG and DBL_DIG >= 10 (and not >=6)?
double
可能等同float
且DBL_DECIMAL_DIG
≥10且FLT_DECIMAL_DIG
≥6的条件一致因为他们对用于 double
和 float
的格式感到满意,因此 DBL_DECIMAL_DIG
= 10 和 FLT_DECIMAL_DIG
= 10.
FLT_DECIMAL_DIG
≥ 6 的条件不是多余的,因为条件被用于 double
的一种格式满足 DBL_DECIMAL_DIG
= 10 而另一种格式用于 float
这样 FLT_DECIMAL_DIG
= 6.
(DBL_DIG
和 FLT_DIG
上面没有讨论但是是类似的。)
Question: if the standard allows DBL_MAX == 1E+37
and DBL_MIN == 1E-37
(i.e. properties of double
== properties of float
), then why it requires DBL_DECIMAL_DIG >= 10
and DBL_DIG >= 10
(and not DBL_DECIMAL_DIG >= 6
and DBL_DIG >= 6
)?
DBL_MAX
和 DBL_MIN
表示指数范围。 DBL_DECIMAL_DIG
和 DBL_DIG
代表精度。这些没有直接关系;可以独立于精度选择指数范围,反之亦然。
N2596 工作草案 — 2020 年 12 月 11 日 ISO/IEC 9899:202x (E):
The values given in the following list shall be replaced by implementation-defined constant expressions with values that are greater than or equal to those shown:
#define DBL_MAX 1E+37 #define FLT_MAX 1E+37
The values given in the following list shall be replaced by implementation-defined constant expressions with (positive) values that are less than or equal to those shown:
#define DBL_MIN 1E-37 #define FLT_MIN 1E-37
The values given in the following list shall be replaced by implementation-defined constant expressions that are greater or equal in magnitude (absolute value) to those shown, with the same sign:
#define DBL_DECIMAL_DIG 10 #define DBL_DIG 10 #define FLT_DECIMAL_DIG 6 #define FLT_DIG 6
问题:如果标准允许 DBL_MAX == 1E+37
和 DBL_MIN == 1E-37
(即 double
的属性 == float
的属性),那么为什么它需要 DBL_DECIMAL_DIG >= 10
和 DBL_DIG >= 10
(而不是 DBL_DECIMAL_DIG >= 6
和 DBL_DIG >= 6
)?
P.S。也许我错过了什么。请指正方向
If C standard allows "double == float", then why it requires DBL_DECIMAL_DIG and DBL_DIG >= 10 (and not >=6)?
double
可能等同float
且DBL_DECIMAL_DIG
≥10且FLT_DECIMAL_DIG
≥6的条件一致因为他们对用于 double
和 float
的格式感到满意,因此 DBL_DECIMAL_DIG
= 10 和 FLT_DECIMAL_DIG
= 10.
FLT_DECIMAL_DIG
≥ 6 的条件不是多余的,因为条件被用于 double
的一种格式满足 DBL_DECIMAL_DIG
= 10 而另一种格式用于 float
这样 FLT_DECIMAL_DIG
= 6.
(DBL_DIG
和 FLT_DIG
上面没有讨论但是是类似的。)
Question: if the standard allows
DBL_MAX == 1E+37
andDBL_MIN == 1E-37
(i.e. properties ofdouble
== properties offloat
), then why it requiresDBL_DECIMAL_DIG >= 10
andDBL_DIG >= 10
(and notDBL_DECIMAL_DIG >= 6
andDBL_DIG >= 6
)?
DBL_MAX
和 DBL_MIN
表示指数范围。 DBL_DECIMAL_DIG
和 DBL_DIG
代表精度。这些没有直接关系;可以独立于精度选择指数范围,反之亦然。