Signed-off-by: Asbjørn Sloth Tønnesen <asbj...@asbjorn.it> --- doc/src/sgml/func.sgml | 13 +++++++++++++ src/backend/utils/adt/float.c | 17 +++++++++++++++-- src/include/catalog/pg_proc.h | 2 ++ src/include/utils/builtins.h | 1 + 4 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 551576a..2b48123 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -878,6 +878,19 @@ <row> <entry> <indexterm> + <primary>tau</primary> + </indexterm> + <literal><function>tau()</function></literal> + </entry> + <entry><type>dp</type></entry> + <entry><quote>τ</quote> constant</entry> + <entry><literal>tau()</literal></entry> + <entry><literal>6.28318530717959</literal></entry> + </row> + + <row> + <entry> + <indexterm> <primary>trunc</primary> </indexterm> <literal><function>trunc(<type>dp</type> or <type>numeric</type>)</function></literal> diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 41b3eaa..1278053 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -26,9 +26,12 @@ #include "utils/sortsupport.h" +#ifndef M_TAU +#define M_TAU 6.28318530717958647693 +#endif + #ifndef M_PI -/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */ -#define M_PI 3.14159265358979323846 +#define M_PI (M_TAU / 2.0) #endif /* Visual C++ etc lacks NAN, and won't accept 0.0/0.0. NAN definition from @@ -1716,6 +1719,16 @@ dpi(PG_FUNCTION_ARGS) /* + * dtau - returns the constant Tau + */ +Datum +dtau(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(M_TAU); +} + + +/* * radians - returns radians converted from degrees */ Datum diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 0b6105b..4148bed 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -1825,6 +1825,8 @@ DATA(insert OID = 1609 ( radians PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 701 DESCR("degrees to radians"); DATA(insert OID = 1610 ( pi PGNSP PGUID 12 1 0 0 0 f f f f t f i 0 0 701 "" _null_ _null_ _null_ _null_ dpi _null_ _null_ _null_ )); DESCR("PI"); +DATA(insert OID = 1611 ( tau PGNSP PGUID 12 1 0 0 0 f f f f t f i 0 0 701 "" _null_ _null_ _null_ _null_ dtau _null_ _null_ _null_ )); +DESCR("Tau"); DATA(insert OID = 1618 ( interval_mul PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1186 "1186 701" _null_ _null_ _null_ _null_ interval_mul _null_ _null_ _null_ )); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index bbb5d39..0258a64 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -408,6 +408,7 @@ extern Datum dsin(PG_FUNCTION_ARGS); extern Datum dtan(PG_FUNCTION_ARGS); extern Datum degrees(PG_FUNCTION_ARGS); extern Datum dpi(PG_FUNCTION_ARGS); +extern Datum dtau(PG_FUNCTION_ARGS); extern Datum radians(PG_FUNCTION_ARGS); extern Datum drandom(PG_FUNCTION_ARGS); extern Datum setseed(PG_FUNCTION_ARGS); -- 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