检查inf-Objective-C [英] Check for inf - Objective-C
本文介绍了检查inf-Objective-C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,当执行1/0运算时,用于测试双精度(或整数)是否为无穷大的方法是什么?
What is the method for testing whether a double (or integer) is infinity, for example when 1/0 operation is performed?
isfinite(n)似乎不起作用.
isfinite(n) does not seem to work.
推荐答案
您可以检查
if(d == INFINITY) {}
或
if(d > DBL_MAX) {}
INFINITY
是在math.h
中定义的常量浮点表达式,表示正无穷大;
DBL_MAX
是在float.h
中定义的常量,代表可以表示的最大双精度数.
INFINITY
is a constant float expression defined in math.h
representing positive infinity;
DBL_MAX
is a constant defined in float.h
representing the largest double that can be represented.
还此处
这篇关于检查inf-Objective-C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文