Преглед изворни кода

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.
Rich Felker пре 3 година
родитељ
комит
75b3412f3d
3 измењених фајлова са 3 додато и 3 уклоњено
  1. 1 1
      src/complex/cproj.c
  2. 1 1
      src/complex/cprojf.c
  3. 1 1
      src/complex/cprojl.c

+ 1 - 1
src/complex/cproj.c

@@ -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;
 }

+ 1 - 1
src/complex/cprojf.c

@@ -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;
 }

+ 1 - 1
src/complex/cprojl.c

@@ -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