fix potentially wrong-sign zero in cproj functions at infinity

these are specified to use the sign of the imaginary part of the input
as the sign of zero in the result, but wrongly copied the sign of the
real part.
This commit is contained in:
Rich Felker 2022-01-18 17:31:46 -05:00
parent 52f0deb969
commit 75b3412f3d
3 changed files with 3 additions and 3 deletions

View File

@ -3,6 +3,6 @@
double complex cproj(double complex z)
{
if (isinf(creal(z)) || isinf(cimag(z)))
return CMPLX(INFINITY, copysign(0.0, creal(z)));
return CMPLX(INFINITY, copysign(0.0, cimag(z)));
return z;
}

View File

@ -3,6 +3,6 @@
float complex cprojf(float complex z)
{
if (isinf(crealf(z)) || isinf(cimagf(z)))
return CMPLXF(INFINITY, copysignf(0.0, crealf(z)));
return CMPLXF(INFINITY, copysignf(0.0, cimagf(z)));
return z;
}

View File

@ -9,7 +9,7 @@ long double complex cprojl(long double complex z)
long double complex cprojl(long double complex z)
{
if (isinf(creall(z)) || isinf(cimagl(z)))
return CMPLXL(INFINITY, copysignl(0.0, creall(z)));
return CMPLXL(INFINITY, copysignl(0.0, cimagl(z)));
return z;
}
#endif