This seems like its worth fixing, if theres a reasonable solution. My understanding is the the current code just punts on handling these corner cases properly
#include <math.h>#include <stdio.h>#include <errno.h>#include <fenv.h>#include <limits.h>#include <float.h>void test(double x, int exp) { errno = 0; feclearexcept(FE_ALL_EXCEPT); printf("(%f)*2^(%d) = %f\n", x, exp, ldexp(x, exp)); printf("errno: %d (ERANGE = %d), UNDERFLOW: %d, OVERFLOW: %d\n", errno, ERANGE, fetestexcept(FE_UNDERFLOW) == FE_UNDERFLOW, fetestexcept(FE_OVERFLOW) == FE_OVERFLOW);}void main() { // If the result overflows, a range error occurs, and the functions // return HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with a sign // the same as x. test(1, 1024); test(1, INT_MAX); // 2^31 - 1 printf("\n"); // If the result underflows, a range error occurs, and zero is // returned. test(1, DBL_MIN_EXP); // Not sure why not getting range error here, test(1, -1074); // or here. test(1, -1075); // but only starting here. test(1, 1 << 31); printf("\n"); // If x is positive infinity (negative infinity), positive infinity // (negative infinity) is returned. test(HUGE_VAL, 1 << 31); test(- HUGE_VAL, 1 << 31);}