Compiling and running the attached program with the command line below
produces the output below:
#include <math.h>
#include <stdio.h>
int main() {
long double a, b;
double c, d;
float f, g;
a = (long double) -INFINITY;
c = (double) -INFINITY;
f = (float) -INFINITY;
b = sqrtl(a);
d = sqrt(c);
g = sqrtf(f);
printf("Long double: %4Lf %4Lf\n", a, b);
printf("Double: %4lf %4lf\n", c, d);
printf("Float: %4f %4f\n", f, g);
return 0;
}
$ gcc -O0 -Og test_sqrt.c -o test_sqrt && ./test_sqrt
Long double: -inf -inf
Double: -inf -nan
Float: -inf -nan
I suspect the behavior for long double should be the same as for double
and float (sqrt(-inf) = nan), but I'm not sure where to change that.
I'm running a snapshot of Cygwin 3.2.0, if that's important.
--
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