Mail Archives: djgpp/1998/01/27/02:27:41
Jeff Taylor <jltaylor AT cyber-quest DOT com> writes:
> The gamma and pow functions
> are not giving me the answers I expect.
> For pow(1.000336, -5) I get Infinity. Is this outside the range of
> pow?
> For gamma(5) I get 3.178, I'm expecting 24. Are there two functions
> called gamma functions?
I think, you forgot to include apropriate header files.
Here is correct program (except for typos):
---
#include <math.h>
#include <stdio.h>
int
main (void)
{
printf ("%g\n", pow (1.000336, -5));
printf ("%g\n", gamma (5)); /* I get 3.17805 here. */
printf ("%g\n", exp (gamma (5))); /* This one gives 24. */
return 0;
}
---
One more thing -- I think it is not DJGPP specific, but a general C
question, so comp.lang.c is more apropriate.
To make it closer to DJGPP, try to remove `#include <math.h>' and run
gcc with `-Wall' switch (and then always use -Wall for compiling your
programs, let compiler catch your mistakes).
BTW, I have not DJGPP references for libc, but man page on Unix here
says that gamma(x) returns ln|GAMMA(x)|, where GAMMA is the
mathematical gamma function (gamma is not in libc and may not be
documented in DJGPP libc references).
- Raw text -