diff --git a/sdk/include/crt/math.h b/sdk/include/crt/math.h index 33f460db5f6..09113acef86 100644 --- a/sdk/include/crt/math.h +++ b/sdk/include/crt/math.h @@ -57,7 +57,21 @@ typedef double double_t; #define HUGE_VALD ((double)INFINITY) #define HUGE_VALF ((float)INFINITY) #define HUGE_VALL ((long double)INFINITY) -#define NAN ((float)(INFINITY * 0.0F)) +#ifndef _UCRT_NEGATIVE_NAN +// This operation creates a negative NAN adding a - to make it positive +#ifdef _MSC_VER +#define NAN (-(float)(INFINITY * 0.0F)) +#else +#define NAN (__builtin_nanf("")) +#endif +#else +// Keep this for backwards compatibility +#ifdef _MSC_VER +#define NAN ((float)(INFINITY * 0.0F)) +#else +#define NAN (-__builtin_nanf("")) +#endif +#endif #define _DENORM (-2) #define _FINITE (-1) diff --git a/sdk/include/ucrt/corecrt_math.h b/sdk/include/ucrt/corecrt_math.h index fdfe1f02e66..215a0b96422 100644 --- a/sdk/include/ucrt/corecrt_math.h +++ b/sdk/include/ucrt/corecrt_math.h @@ -91,10 +91,18 @@ _CRT_BEGIN_C_HEADER #define HUGE_VALL ((long double)INFINITY) #ifndef _UCRT_NEGATIVE_NAN // This operation creates a negative NAN adding a - to make it positive +#ifdef _MSC_VER #define NAN (-(float)(INFINITY * 0.0F)) #else +#define NAN (__builtin_nanf("")) +#endif +#else // Keep this for backwards compatibility +#ifdef _MSC_VER #define NAN ((float)(INFINITY * 0.0F)) +#else +#define NAN (-__builtin_nanf("")) +#endif #endif #define _DENORM (-2)