Login  Register

Re: math constants

Posted by Luigi Ballabio on Nov 13, 2015; 3:51pm
URL: http://quantlib.414.s1.nabble.com/math-constants-tp17029p17069.html

Yes, it might make sense.  But truth be told, I'd be for having less of them rather than more.  Which of the macros are already defined by the compilers we support?

Luigi


On Wed, Nov 4, 2015 at 10:38 AM Peter Caspers <[hidden email]> wrote:
Hello Luigi, all,

I had a typo in my code and used M_SQRT_2 instead of M_SQRT2, the
former being defined as 1 / sqrt(2), but what I wanted was sqrt(2). We
also have a macro M_SQRT1_2 with the same value and which seems to
have a better name. I find M_SQRT_2 quite confusing and non-intuitive,
so I am wondering if we could just deprecate it and remove it in one
of the next versions ?

There are also some constants whose meaning does not appear
crystal-clear at first sight (M_IVLN10, M_LN2LO, M_LN2HI, M_INVLN2).
Can someone provide a definition, so that we can maybe add them to the
source ?

Finally there are some constants with many digits (M_SQRT1_2, M_PI).
Since there is no specifier (L) I guess they are always mapped to
double by the compiler, which should be 64bit on every platform, so
effectively they won't help even if one uses them to initialize a
__float128 etc. ? Maybe we should rather do it like GNU and add
versions of the macros like M_PIl, M_SQRT1_2l defining more digits and
with the L suffix ? Then we would also be in line with gcc.

What do you think ?

Best regards
Peter

------------------------------------------------------------------------------
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
--

<http://leanpub.com/implementingquantlib>
<http://implementingquantlib.com>
<http://twitter.com/lballabio>


------------------------------------------------------------------------------

_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev