问题描述
我知道< cmath> isinf(c ++ 11)或更早版本< float.h> _finite函数/宏测试给定的浮点数是否为
EITHER 正无穷大 OR 负无穷大但我想知道某个数字是否只是正无穷大I.E.与isinf或_finite不同,IsPositiveInfinity(-1.0 / 0.0)返回
false 同样我想知道是否有办法测试浮点数是否只是负无穷大I.E. IsNegativeInfinity(numeric_limits< double> :: infinity())也返回false,因为numeric_limits< double> :: infinity()
返回double类型的正无穷大值!
I我不想发布这个,但我在整个互联网上找不到这个问题的答案,所以我别无选择!太奇怪了!
I know that the <cmath> isinf (c++11) or older <float.h> _finite functions/macros test whether the given floating point number isEITHER positive infinity OR negative infinity But I want to know if some number is just positive infinity I.E. IsPositiveInfinity(-1.0 / 0.0) returnsfalse unlike isinf or _finite Also I want to know if there is a way to test whether a floating point number is just negative infinity I.E. IsNegativeInfinity(numeric_limits<double>::infinity()) also returns false, because numeric_limits<double>::infinity() returns positive infinity value of type double!
I didn't want to post this, but I couldn't find answer to this question in the whole internet, so I don't have no choice! So weird!
这篇关于如何在C ++中检查浮点数是正无穷大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!