]> granicus.if.org Git - postgresql/commitdiff
Yet further adjust degree-based trig functions for more portability.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 24 Jan 2016 17:53:03 +0000 (12:53 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 24 Jan 2016 17:53:03 +0000 (12:53 -0500)
Buildfarm member cockatiel is still saying that cosd(60) isn't 0.5.
What seems likely is that the subexpression (1.0 - cos(x)) isn't being
rounded to double width before more arithmetic is done on it, so force
that by storing it into a variable.

src/backend/utils/adt/float.c

index 788c17033f2dbb43381b4be553b9d40f220ad97e..d4e5d553477a321ba431ff14256cae73af2caa23 100644 (file)
@@ -2000,7 +2000,9 @@ sind_0_to_30(double x)
 static double
 cosd_0_to_60(double x)
 {
-       return 1.0 - ((1.0 - cos(x * RADIANS_PER_DEGREE)) / one_minus_cos_60) / 2.0;
+       float8          one_minus_cos_x = 1.0 - cos(x * RADIANS_PER_DEGREE);
+
+       return 1.0 - (one_minus_cos_x / one_minus_cos_60) / 2.0;
 }