math - How can I calculate the factorial of a double in c++ -
i hoping there library function somewhere can this. , yes important factorial of double value (that needs work non-integer values).
the c99 standard library contains gamma function, double tgamma(double)
. closely related factorial, can define:
#include <cmath> double factorial(double x) {return std::tgamma(x+1);}
this should available in c++11 implementation, not guaranteed in c++03 implementation, might include c90 library. if implementation doesn't have it, boost.math library does.
Comments
Post a Comment