This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Re: [PATCH] C++ math constants
- From: 3dw4rd at verizon dot net
- To: a dot teal at warwick dot ac dot uk, drepper at gmail dot com
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Feb 2013 12:34:12 -0600 (CST)
- Subject: Re: Re: [PATCH] C++ math constants
On 02/21/13, Alec Teal<a.teal@warwick.ac.uk> wrote:
On 21/02/13 16:32, Ulrich Drepper wrote:
> How about the attached file as a start for <ext/math>. I used the
> constexpr approach (instead of function calls) and replicated the
> constants that are available in <math.h> in Unix.
>
> What other constants to add?
Pi/3
ln(3)
ln(10) (for base conversions)
sqrt(3)
sqrt(5)
sqrt(7)
1/e
I'll write down what I use in my day to day stuff, keep you posted.
I use the Euler constant a *lot* in special functions. Also, I use the golden ratio to size dialog boxes in GUI work.
// Constant @f$ @f$.
static constexpr _RealType __pi_third(1.0471975511965977461542144610931676L);
// Constant @f$ \gamma_E @f$.
static constexpr _RealType __gamma_e(0.5772156649015328606065120900824024L);
// Constant @f$ \phi = (1 + \sqrt(5))/2 @f$.
static constexpr _RealType __golden_ratio(1.6180339887498948482045868343656381L);