How to represent infinity in Objective-C?

后端 未结 1 1164
情歌与酒
情歌与酒 2021-01-12 09:16

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

相关标签:
1条回答
  • 2021-01-12 10:12

    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

    0 讨论(0)
提交回复
热议问题