如果在类型完成的计算没有舍入误差,测试。
static const bool is_exact = false;
返回值
true,如果计算没有舍入错误; false,如果没有。
备注
所有预定义的整数类型有自己的值的确切表示形式并返回 false。一个定点或合理的表示形式也视为完全相同,但是,浮点表示不是。
示例
// numeric_limits_is_exact.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<float>::is_exact
<< endl;
cout << "Whether double objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<double>::is_exact
<< endl;
cout << "Whether long int objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<long int>::is_exact
<< endl;
cout << "Whether unsigned char objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<unsigned char>::is_exact
<< endl;
}
要求
标头: <limits>
命名空间: std