问题
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