Difference between exponents for indices in C++
Dec 26, 2017 at 1:09pm UTC
Could someone simply tell me the difference between e, exp and pow. In my program I like to use the indices 2.5x10^-3 for example so which one from above should I use:
2.5*pow(10,-3.0)
or
2.5e-3
or
2.5*exp(-3.0).
Thank you.
Dec 26, 2017 at 1:16pm UTC
2.5e-3 is the built in notation for floating point numbers (
float
,
double
,
long double
) , so use that.
2.5*pow(10,-3.0) is an inefficient way of doing the same thing.
2.5*exp(-3.0). is the same as 2.5 * pow(e, -3.0) where e is Euler's number ~ 2.7182818284590452353602874713527
http://en.cppreference.com/w/cpp/numeric/math/exp
Last edited on Dec 26, 2017 at 1:17pm UTC
Dec 26, 2017 at 1:27pm UTC
Last edited on Dec 26, 2017 at 1:28pm UTC
Dec 26, 2017 at 4:06pm UTC
Thanks you for the help guys. Really helpful
Topic archived. No new replies allowed.