c++ The power function implementation

Started by
1 comment, last by Misery 12 years ago
Hello,

I need to create a flexible and quite general power function that would allow me to make such operation as


p=x^y;


But it should be able to work on wide range of arguments like for example:

p=-0.4^-(0.25)


and not only for integers or positive values. Because for example

p=pow(x,y)


C++ function returns an error.
Thanks in advance,
Misery
Advertisement
The result of -0.4 ^ -0.25 is a complex number so you should just use the complex functions in the standard library.

#include <complex>

and you're good to go.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
lol... in fact You're right. :]
thanks a lot!

This topic is closed to new replies.

Advertisement