发表于:2006-05-30 09:02:00
5楼
cooker兄对CITECT的理解应用能力是我辈所景仰的.
按你的方法俺也试了,剔除了无效点然后再调用tablemath,可是结果还是一样.
对于数学运算,出现无意义的结果,可以参考一下下面的定义:
template<class T>
class numeric_limits {
public:
static const bool has_denorm = false;
static const bool has_denorm_loss = false;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const bool is_bounded = false;
static const bool is_exact = false;
static const bool is_iec559 = false;
static const bool is_integer = false;
static const bool is_modulo = false;
static const bool is_signed = false;
static const bool is_specialized = false;
static const bool tinyness_before = false;
static const bool traps = false;
static const float_round_style round_style = round_toward_zero;
static const int digits = 0;
static const int digits10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int radix = 0;
static T denorm_min() throw();
static T epsilon() throw();
static T infinity() throw();
static T max() throw();
static T min() throw();
static T quiet_NaN() throw();
static T round_error() throw();
static T signaling_NaN() throw();
};
如果调用Cout<<numeric_limits<float>::quiet_NaN() << endl;则会返回-1.#IND.所以算式应该是抛出了异常如:
try
{
}
catch(...){
return quiet_NaN();
}
NaN代表"Not a Number",确实代表算式中存在无意义的值.
但我使用istrnvalidvalue检测后,把有效值输入到另外一个数组,然后再用tablemath还是出现这个现象,我不太清楚了...