如何在Objective-C中表示无穷大? [英] How to represent infinity in Objective-C?
本文介绍了如何在Objective-C中表示无穷大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在 Objective-C 中表示无穷大(作为浮点数/双精度数或 NSNumber 等)?换句话说,在 Objective-C 中是否有一个 float/double/NSNumber 值总是大于任何其他值?
Is there a way to represent infinity (as a float/double, or NSNumber, etc.) in Objective-C? In other words, is there a float/double/NSNumber value that is always larger than any other value in Objective-C?
推荐答案
INFINITY
有一个宏,
float x = INFINITY;
你可以在 usr/include/math.h 中找到它
You can find this in usr/include/math.h
# define HUGE_VALF __builtin_huge_valf()
...
#define INFINITY HUGE_VALF
编辑这里有一些更有趣的阅读
Edit Some more interesting read here
http://www.gnu.org/软件/libc/manual/html_node/Infinity-and-NaN.html
这篇关于如何在Objective-C中表示无穷大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文