#include <stdint.h>
#ifdef CORE_MATH_SUPPORT_ERRNO
#include <errno.h>
#endif
#include <fenv.h>
#include <math.h>
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#endif
#pragma STDC FENV_ACCESS ON
typedef union {_Float16 f; uint16_t u;} b16u16_u;
typedef union {double f; uint64_t u;} b64u64_u;
_Float16 cr_hypotf16(_Float16 x, _Float16 y){
b64u64_u tx = {.f = x};
b64u64_u ty = {.f = y};
double ret = __builtin_sqrt(tx.f * tx.f + ty.f * ty.f);
#ifdef CORE_MATH_SUPPORT_ERRNO
int rnd = fegetround();
if (rnd == FE_TONEAREST) { if (ret < 0x1.ffep-15 && (double) (_Float16) ret != ret) errno = ERANGE;
if (ret >= 0x1.ffep+15)
errno = ERANGE;
}
if (rnd == FE_TOWARDZERO || rnd == FE_DOWNWARD) { if (ret < 0x1p-14 && (double) (_Float16) ret != ret) errno = ERANGE;
if (ret > 0x1p+16)
errno = ERANGE;
}
if (rnd == FE_UPWARD) { if (ret < 0x1.ffcp-15 && (double) (_Float16) ret != ret) errno = ERANGE;
if (ret > 0x1.ffcp+15)
errno = ERANGE;
}
#endif
return ret;
}
_Float16 hypotf16 (_Float16 x, _Float16 y) {
return (_Float16) hypotf ((float) x, (float) y);
}