I am trying to find the more 'natural' way to use the number e in C/C++. I am focused on calculating the function e^n.
I think that 'cmath', by default, does not provide support for both (function and constant). However, it can be enabled to include constants defined by the compiler, in this case, M_E
. This can be done by including the statement #define _USE_MATH_DEFINES
.
On the other hand, e can be defined as a constant:
#define E 2.71828182845904523536;
or
const double EULER = 2.71828182845904523536;
Said this. Which one is the most 'standard' way to approach to this mathematical constant? Is it any other library?
n
an integer, real, or complex? Only if it's an integer, willstd::pow(Euler,n)
possibly be more efficient than simplystd::exp(n)
. – Walter