Modeling infinity for the largest double value

后端 未结 9 1423
予麋鹿
予麋鹿 2020-12-31 05:10

The question is about modeling infinity in C++ for the double data type. I need it in a header file, so we cannot use functions like numeric_limits

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 06:00

    #include 
    ...
    double d = INFINITY;
    

    You can find INFINITY defined in (math.h):

    A constant expression of type float representing positive or unsigned infinity, if available; else a positive constant of type float that overflows at translation time.

提交回复
热议问题