From: | Asbjørn Sloth Tønnesen <asbjorn(at)asbjorn(dot)it> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Asbjørn Sloth Tønnesen <asbjorn(at)asbjorn(dot)it> |
Subject: | [PATCH 2/3] backend: use M_TAU instead of M_PI |
Date: | 2014-06-28 00:52:23 |
Message-ID: | d64eada8e0a0dd853a1aa97068874217080b0b21.1403915555.git.asbjorn@asbjorn.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Signed-off-by: Asbjørn Sloth Tønnesen <asbjorn(at)asbjorn(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Asbjørn Sloth Tønnesen | 2014-06-28 00:52:24 | [PATCH 3/3] earthdistance: TWO_PI => M_TAU |
Previous Message | Asbjørn Sloth Tønnesen | 2014-06-28 00:52:22 | [PATCH 1/3] Implement tau() function |