为什么C ++标准没有提到__STDC_IEC_559__? [英] Why does the C++ standard not mention __STDC_IEC_559__?
问题描述
根据C ++ 11标准[c.math],< cmath>
头与标准C库头 math.h>
。
(当然,有几个区别,---命名空间,重载等等---但这里可以忽略。)
根据C99标准附录F,定义 __ STDC_IEC_559 __
的实现应符合附录F中的规范。
例如。如果两个参数都为零,则 atan2
可能会导致域错误,但如果定义 __ STDC_IEC_559 __
p>
在C99中,许多行为也取决于是否定义 __ STDC_IEC_559 __
。
但是,似乎在C ++ 11标准中没有提及 __ STDC_IEC_559 __
。
如果是这样,实现符合附件F中的规范?
我认为 std :: numeric_limits< T> :: is_iec559()$ c
C ++标准(n3797)包括C标准库,见参考文件s1.2 / 2。
ISO / IEC 9899:1999第7条和ISO / IEC 9899:1999 / Cor.1中第7条所述的库: 2001
和ISO / IEC 9899:1999 / Cor.2:2003的第7条以下称为C标准库。
18到30,在C.4中,C标准库是C ++标准
库的子集。
标准中没有提到该符号,我不会期望它被定义,因为它似乎是标准C的特定。通过不定义该符号,C ++不受附件F的内容的约束。
相反,C ++标准包含了更多类似C ++的形式的多个IEC 559提及。例如
对于
is_iec559!= false
在18.3.2.4/56中有具体的提及。
static constexpr bool is_iec559;
当且仅当类型符合IEC 559 standard.218时才为true
对所有浮点类型都有意义。
我认为C ++包含所有相同能力(或缺乏),但适应C ++世界。
According to C++11 standard [c.math], the <cmath>
header is same as Standard C library header <math.h>
.
(Of course, there are several differences, --- namespace, overloads etc. --- but these can be ignored here.)
And according to C99 standard annex F, "An implementation that defines __STDC_IEC_559__
shall conform to the specifications in" the annex F.
Ex. The atan2
may cause a domain error if both arguments are zero, but It must not if __STDC_IEC_559__
is defined.
In C99, many behavior is also dependent on whether __STDC_IEC_559__
is defined or not.
However, it seems that __STDC_IEC_559__
is not mentioned anywhere in C++11 standard.
If so, shall a C++ implementation conform to the specifications in the annex F?
I think that std::numeric_limits<T>::is_iec559()
is a substitute, but it seems to mention about only type.
The C++ standard (n3797) includes the C standard library by reference, see s1.2/2.
The library described in Clause 7 of ISO/IEC 9899:1999 and Clause 7 of ISO/IEC 9899:1999/Cor.1:2001 and Clause 7 of ISO/IEC 9899:1999/Cor.2:2003 is hereinafter called the C standard library.
With the qualifications noted in Clauses 18 through 30 and in C.4, the C standard library is a subset of the C++ standard library.
The standard contains no mention of that symbol, and I would not expect it be defined, since it appears to be specific to Standard C. By not defining that symbol, C++ is not bound by the contents of Annex F.
Instead the C++ standard contains multiple mentions of IEC 559 in a rather more C++-like form. For example,
Shall be true for all specializations in which
is_iec559 != false
There is a specific mention in 18.3.2.4/56.
static constexpr bool is_iec559;
True if and only if the type adheres to IEC 559 standard.218
Meaningful for all floating point types.
I think it would be fair to say that C++ includes all the same capabilities (or lack of them), but adapted to the C++ world.
这篇关于为什么C ++标准没有提到__STDC_IEC_559__?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!