Document M_PI and friends in <QtMath>

These symbols should at least be mentioned in the documentation.
Also comment on the option of using template variables for them once
we haev support for C++14

Change-Id: Ia40f9b89d9d8a38536a2e51ae3f174b8f16ca7d6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Edward Welbourne 2017-03-22 14:46:27 +01:00
parent 8d49df2172
commit b4c85e8a2a
2 changed files with 20 additions and 1 deletions

View File

@ -149,6 +149,8 @@ inline qreal qPow(qreal x, qreal y)
return pow(x, y);
}
// TODO: use template variables (e.g. Qt::pi<type>) for these once we have C++14 support:
#ifndef M_E
#define M_E (2.7182818284590452354)
#endif

View File

@ -35,7 +35,24 @@
These functions are partly convenience definitions for basic math operations
not available in the C or Standard Template Libraries.
\pagekeywords math trigonometry qmath floor ceiling absolute sine cosine tangent inverse tan exponent power natural logarithm
The header also ensures some constants specified in POSIX, but not present
in C++ standards (so absent from <math.h> on some platforms), are defined:
\value M_E The base of the natural logarithms, e = exp(1)
\value M_LOG2E The base-two logarithm of e
\value M_LOG10E The base-ten logarithm of e
\value M_LN2 The natural logarithm of two
\value M_LN10 The natural logarithm of ten
\value M_PI The ratio of a circle's circumference to diameter, \unicode{0x3C0}
\value M_PI_2 Half M_PI, \unicode{0x3C0} / 2
\value M_PI_4 Quarter M_PI, \unicode{0x3C0} / 4
\value M_1_PI The inverse of M_PI, 1 / \unicode{0x3C0}
\value M_2_PI Twice the inverse of M_PI, 2 / \unicode{0x3C0}
\value M_2_SQRTPI Two divided by the square root of pi, 2 / \unicode{0x221A}\unicode{0x3C0}
\value M_SQRT2 The square root of two, \unicode{0x221A}2
\value M_SQRT1_2 The square roof of half, 1 / \unicode{0x221A}2
\pagekeywords math trigonometry qmath floor ceiling absolute sine cosine tangent inverse tan exponent power natural logarithm pi
*/
/*!