Signed-off-by: Asbjørn Sloth Tønnesen <asbj...@asbjorn.it>
---
 src/backend/utils/adt/float.c   | 4 ++--
 src/backend/utils/adt/geo_ops.c | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 1278053..b0211f8 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -1701,7 +1701,7 @@ degrees(PG_FUNCTION_ARGS)
        float8          arg1 = PG_GETARG_FLOAT8(0);
        float8          result;
 
-       result = arg1 * (180.0 / M_PI);
+       result = arg1 * (360.0 / M_TAU);
 
        CHECKFLOATVAL(result, isinf(arg1), arg1 == 0);
        PG_RETURN_FLOAT8(result);
@@ -1737,7 +1737,7 @@ radians(PG_FUNCTION_ARGS)
        float8          arg1 = PG_GETARG_FLOAT8(0);
        float8          result;
 
-       result = arg1 * (M_PI / 180.0);
+       result = arg1 * (M_TAU / 360.0);
 
        CHECKFLOATVAL(result, isinf(arg1), arg1 == 0);
        PG_RETURN_FLOAT8(result);
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index 54391fd..429de6d 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -23,8 +23,12 @@
 #include "utils/builtins.h"
 #include "utils/geo_decls.h"
 
+#ifndef M_TAU
+#define M_TAU 6.28318530717958647693
+#endif
+
 #ifndef M_PI
-#define M_PI 3.14159265358979323846
+#define M_PI (M_TAU / 2.0)
 #endif
 
 
@@ -5168,7 +5172,7 @@ circle_poly(PG_FUNCTION_ARGS)
        SET_VARSIZE(poly, size);
        poly->npts = npts;
 
-       anglestep = (2.0 * M_PI) / npts;
+       anglestep = M_TAU / npts;
 
        for (i = 0; i < npts; i++)
        {
-- 
2.0.0



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to