tags:

views:

243

answers:

3

Another basic question I just must ask.

Any answer is much appreciated.

+12  A: 

exp(x) returns e (the base of natural logarithms) raised to the power of x.

exp10(x) returns 10 raised to the power of x.

Niels Castle
@Johannes: why the edit?
Henrik
Henrik: Added links to the respective manpages. And sorry for the lost 10. Didn't notice :-(
Joey
May I ask how do I implement it in C? I typed the code in and I also included math.h but it comes up as error during build: error: `exp10' was not declared in this scopeHow do I declare it? Thx.
Victor
ext10 is a GNU extension to the C language (GNU compiler collection)
rcs
`double pow (double base, double power)` is a more general exponentiation function in the standard library, returning *base* raised to *power*.
rcs
+4  A: 
  • exp: compute e (the base of natural logarithms) raised to the power x
  • exp10: compute 10 raised to the power x. Mathematically, exp10(x) is the same as exp(x*log(10)), where log(x) is the logarithm to the base e (Euler number).
rcs
actually it's `exp(x*ln(10))` :-)
Nick D
log(x) ... in my notation the base of the logarithm is chosen as e
rcs
A: 

You should first check your handy C reference manual for questions like this, rather than going online. According to mine ("C: A Reference Manual", Harbison & Steele, 5th ed.), exp10() is not part of the standard C math library; it appears to be a GNU-specific extension.

You should be able to get the same result using the standard library function pow():

#include <math.h>
int x = ...;
double v = pow(10.0, x);
John Bode