关于整型数的溢出问题
今天在看一个开源程序中,看到了下面的代码
/* Yes, this is exceedingly ugly. Blame Microsoft, which hopelessly */
/* violates the IEEE 754 floating-point standard in a bizarre way. */
/* If you're using an IEEE 754-compliant compiler, then x != x is true */
/* iff x is NaN. For Microsoft, (x < x) is true iff x is NaN. */
/* So either way, this macro safely detects a NaN. */
#define SCALAR_IS_NAN(x) (((x) != (x)) || (((x) < (x))))
/* true if an integer (stored in double x) would overflow (or if x is NaN) */
#define INT_OVERFLOW(x) ((!((x) * (1.0+1e-8) <= (double) Int_MAX)) \
|| SCALAR_IS_NAN (x))
SCALAR_IS_NAN我能理解,关键是INT_OVERFLOW宏前面的部分!((x) * (1.0+1e-8) <= (double) Int_MAX)
用来判定浮点数溢出?不知道怎么就能判定的呢?请各位高手帮助解答!小弟不胜感激!