From cppreference.com
Defined in header
#define HUGE_VALF /* implementation defined */(since C++11)#define HUGE_VAL /* implementation defined */#define HUGE_VALL /* implementation defined */(since C++11)The macros HUGE_VALF, HUGE_VAL and HUGE_VALL macros expand to positive floating point constant expressions which compare equal to the values returned by floating-point functions and operators in case of overflow (see
).
Constant Explanation HUGE_VALFExpands to positive float expression that indicates overflow HUGE_VALExpands to positive double expression that indicates overflow, not necessarily representable as a floatHUGE_VALLExpands to positive longdouble expression that indicates overflow, not necessarily representable as a float or doubleOn implementations that support floating-point infinities, these macros always expand to the positive infinities of float, double, and longdouble, respectively.
Notes
On implementations that do not support floating-point infinities, these macros expand to the maximum finite number of their respective types.
C++98 added float and longdouble overloads of mathematical functions. There is a problem that the float overloads cannot return HUGE_VAL to indicate overflow because this macro is not guaranteed to be representable as a float.
was raised to target this problem. LWG found that C99 has the same problem (float and longdouble overloads were also added in C99), and C99 introduced new macros HUGE_VALF and HUGE_VALL to solve the problem. Therefore the issue was closed and the C99 resolution was adopted in C++11.
See also