This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] tau support in math.h
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Adam Talsma <adam at talsma dot ca>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 28 Jan 2013 12:05:03 +0100
- Subject: Re: [PATCH] tau support in math.h
- References: <CA+a0djN1QVyqa3um-H+GSKCR9g-u54=ab1K8=R91qw8JAxaguA@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Jan 28, 2013 at 12:18:20AM -0800, Adam Talsma wrote:
> This patch adds tau as a macro in math.h. This should allow for efficiency
> improvements as higher level math functions will inevitably be refactored away
> from using 2pi.
What exact improvements it has over using 2 * M_PI ? Multiplication by two
just changes the exponent of the constant, not the mantissa (as M_PI is not
subnormal nor too large), so it is exactly as precise as this.
M_TAU isn't standardized (and, btw, you got your patch wrong, there was no l
suffix in the second snippet), you are free to define it in whatever project
you prefer to use a constant like that.
> --- math.h 2013-01-27 23:35:53.377637077 -0800
> +++ math.h.tau 2013-01-28 00:02:40.721703715 -0800
> @@ -364,6 +364,7 @@
> # define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
> # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
> # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
> +# define M_TAU 6.28318530717958647692 /* tau */
> #endif
>
> /* The above constants are not adequate for computation using `long double's.
> @@ -383,6 +384,7 @@
> # define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
> # define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
> # define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
> +# define M_TAU 6.283185307179586476925286766559005768L /* tau */
> #endif
Jakub