sqrtl behavior inconsistent with sqrt and sqrtf
airplanemath
airplanemath@aol.com
Tue Oct 27 11:44:32 GMT 2020
airplanemath via Cygwin <cygwin@cygwin.com> writes:
> Compiling and running the attached program with the command line below
> produces the output below:
>
> $ 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.
The mail archive says I'm bad at attaching things.
Program source included 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;
}
More information about the Cygwin
mailing list