computing floating point powers

Quote:

(DAVID KOIDL) writes:

> i need to evaluate the expression e^(-at) where -at is a float value

> as well.can anybody please help me with this.

Do you mean e as in Euler's number? Or just a general float value?

For the latter, use pow(), for the former use exp() -- both are

defined in <math.h>:

#include <math.h>

double foo = pow(0.35, -1.13);

float bar = powf(2.0, 0.5);

double baz = exp(2 * 3.1415926535984);

float frob = expf(7.0);

Remember that you may have to link your program against additional

math libraries when you compile (depending on the system you're

using).

Cheers,

-M

-- . -.. .. .- . ...- .- .-.. .. ... - -.-. --- -- .--. --- ... . .-.

Michael J. Fromberger

Software Engineer, Thayer School of Engineering

Dartmouth College, Hanover, New Hampshire, USA

--. ..- .. - .- .-. .. ... - .-.. .. -. --. ..- .. ... - -- .--- ..-.

"Alway the nye slye maketh the ferre leeve to be looth."