How to represent infinity in objective C?

天大地大妈咪最大 提交于 2020-01-02 04:56:06

问题


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?


回答1:


There's a macro for this INFINITY,

float x = INFINITY;

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/software/libc/manual/html_node/Infinity-and-NaN.html



来源:https://stackoverflow.com/questions/30544334/how-to-represent-infinity-in-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!