Given that hypot(DBL_MAX, 0.0) = DBL_MAX and hypotf(FLT_MAX, 0.0f) =
FLT_MAX, I suspect this is a problem in hypotl.  Am I missing something?

There is a similar difference in cabsl compared to cabs and cabsf, which
probably has a similar cause.

I attached my test case, which I compile with
gcc -Og -O0 test_cabs_hypot.c -o test_cabs_hypot

What should I expect here?

#include <complex.h>
#include <float.h>
#include <math.h>
#include <stdio.h>

int main(void) {
  _Complex long double test_cabsl = LDBL_MAX + 0.0L * _Complex_I;
  long double test_hypotl1 = LDBL_MAX, test_hypotl2 = 0.0L;
  _Complex double test_cabs = DBL_MAX + 0.0L * _Complex_I;
  double test_hypot1 = DBL_MAX, test_hypot2 = 0.0L;
  _Complex float test_cabsf = FLT_MAX + 0.0L * _Complex_I;
  float test_hypotf1 = FLT_MAX, test_hypotf2 = 0.0L;

  printf("cabsl(%Lg%+Lgi) = %Lg\n", creall(test_cabsl), cimagl(test_cabsl), cabsl(test_cabsl));
  printf("hypotl(%Lg, %Lg) = %Lg\n\n", test_hypotl1, test_hypotl2, hypotl(test_hypotl1, test_hypotl2));

  printf("cabs(%lg%+lgi) = %lg\n", creal(test_cabs), cimag(test_cabs), cabs(test_cabs));
  printf("hypot(%lg, %lg) = %lg\n\n", test_hypot1, test_hypot2, hypot(test_hypot1, test_hypot2));

  printf("cabsf(%g%+gi) = %g\n", crealf(test_cabsf), cimagf(test_cabsf), cabsf(test_cabsf));
  printf("hypotf(%g, %g) = %g\n\n", test_hypotf1, test_hypotf2, hypotf(test_hypotf1, test_hypotf2));
  return 0;
}
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to